Is
public event Action delt = () => { Console.WriteLine("Information"); };
an overloaded version of
Action<int, int> delg = (a, b) => { Console.WriteLine( a + b); }; ?
I mean Action<> delegate is an overloaded version of "event Action"?
It's not called an overload.
Basically, there is a set of types, declared like this:
namespace System {
delegate void Action();
delegate void Action<T>(T a);
delegate void Action<T1, T2>(T1 a1, T2 a2);
...
}
Each of them is a different type, independent of all other. The compiler knows which type you mean when you try to reference it by the presence or absence of <>
after the type name, and the number of type parameters within <>
.
event
is a different thing altogether, and doesn't play any part in this. If you're confused by the difference between event and delegate, see these two questions: 1 2
The event isn't "Action", it is called 'delt', and it has an EventHandler delegate of type Action. Normally you'd want your events to have an EvenHandler conforming to the standard eventing model (e.g. MyHandler(object sender, InheritsFromEventArgs argument))
Action and Action<> are delegate types and exist as part of the System namespace.
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