C
Join ServerC#
help
Why is the generic delegate does not accept my method?
Pphattanuki8/13/2022
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?

Tthinker2278/13/2022
GetPLCName
does not take a string
as a parameterTthinker2278/13/2022
The required delegate here is
string Key(string key)
Pphattanuki8/13/2022
delegate T Key<T>();
Pphattanuki8/13/2022
ah, the delegate needed to be declared like this
Pphattanuki8/13/2022
but this makes it so that the delegate can not take any arguments
Tthinker2278/13/2022
yes
Pphattanuki8/13/2022
which would be incorrect in my place, since I want the methods to take in arguments...and sometimes not
Pphattanuki8/13/2022
huh
Tthinker2278/13/2022
Well, you can't do that
Tthinker2278/13/2022
A delegate has to match the exact definition
Pphattanuki8/13/2022
ah, makes sense now
Pphattanuki8/13/2022
thank you
Tthinker2278/13/2022
You can't have "sometimes takes arguments, sometimes not"
Tthinker2278/13/2022
np 

Pphattanuki8/13/2022
huh, how do I do that?
Tthinker2278/13/2022
forgot 't
Pphattanuki8/13/2022
😄
Pphattanuki8/13/2022
okay,thank you, how do I close the post? mark it as "resolved" or something?
Tthinker2278/13/2022
idk how these forums threads really work yet 
