Why is the generic delegate does not accept my method?
I've created a generate delegate as a test and wanted it to assign it to a variable, but it seems it's not accepting it. Did I make a mistake in the syntax or in the design of this?
11 Replies
GetPLCName
does not take a string
as a parameter
The required delegate here is string Key(string key)
ah, the delegate needed to be declared like this
but this makes it so that the delegate can not take any arguments
yes
which would be incorrect in my place, since I want the methods to take in arguments...and sometimes not
huh
Well, you can't do that
A delegate has to match the exact definition
ah, makes sense now
thank you
You can't have "sometimes takes arguments, sometimes not"
np
huh, how do I do that?
forgot 't
😄
okay,thank you, how do I close the post? mark it as "resolved" or something?
idk how these forums threads really work yet