❔ What of use is the identifier for the delegate?

I do think
public delegate void NumManipulationHandler(string state);
public delegate void NumManipulationHandler(string state);
can be modified into
public delegate void NumManipulationHandler(string);
public delegate void NumManipulationHandler(string);
but it hates to do it.
7 Replies
Thinker
Thinker16mo ago
Afaik there is literally no purpose to it, other than perhaps being able to use named arguments
thirteenbinary
thirteenbinary16mo ago
Could you please give an example for the named arguments related to it?
MODiX
MODiX16mo ago
thinker227#5176
REPL Result: Success
delegate void Foo(int a, string b);

Foo foo = (a, b) => Console.WriteLine($"{b} {a}");
foo(b: "abc", a: 2);
delegate void Foo(int a, string b);

Foo foo = (a, b) => Console.WriteLine($"{b} {a}");
foo(b: "abc", a: 2);
Console Output
abc 2
abc 2
Compile: 689.734ms | Execution: 107.104ms | React with ❌ to remove this embed.
Thinker
Thinker16mo ago
Ex. like this, being able to put the arguments out of order when calling the delegate
thirteenbinary
thirteenbinary16mo ago
Thank u.
jcotton42
jcotton4216mo ago
Or bool arguments I nearly always name bool arguments when using a literal
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.