Why must we specify the parameter name x
as follows
public delegate void XXX(int x);
when declaring a delegate type?
For me, the parameter name x
is unused so it will be simpler if we can rewrite as follows:
public delegate void XXX(int);
Please let me know why the C# designer "forced" us to specify the parameter names.
Is public delegate TResult Func<T1,TResult>(T1 arg1)
more readable than public delegate TResult Func<T1,TResult>(T1)
?
It is used:
In both cases this name adds meaning that aids the developer. For example, I have no idea what your x
represents - but name it something better and I'll have a clue.
As an alternative, use Action<int>
and forget about it.
Probably the same reason as you are forced to specify the name of a method parameter. For one thing it helps to document the purpose of the parameter.
Which is more readable?
public delegate void EventHandler(object source, EventArgs e);
public delegate void EventHandler(object, EventArgs);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With