C
C#•3y ago
phattanuki

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
Thinker
Thinker•3y ago
GetPLCName does not take a string as a parameter The required delegate here is string Key(string key)
phattanuki
phattanukiOP•3y ago
delegate T Key<T>();
delegate T Key<T>();
ah, the delegate needed to be declared like this but this makes it so that the delegate can not take any arguments
Thinker
Thinker•3y ago
yes
phattanuki
phattanukiOP•3y ago
which would be incorrect in my place, since I want the methods to take in arguments...and sometimes not huh
Thinker
Thinker•3y ago
Well, you can't do that A delegate has to match the exact definition
phattanuki
phattanukiOP•3y ago
ah, makes sense now thank you
Thinker
Thinker•3y ago
You can't have "sometimes takes arguments, sometimes not" np catsip
phattanuki
phattanukiOP•3y ago
huh, how do I do that?
Thinker
Thinker•3y ago
forgot 't
phattanuki
phattanukiOP•3y ago
😄 okay,thank you, how do I close the post? mark it as "resolved" or something?
Thinker
Thinker•3y ago
idk how these forums threads really work yet catshy
Want results from more Discord servers?
Add your server