Non-generic delegate declaration is done as follows:
delegate void Print(int arg);
where void is a return type and int is the argument type.
A Generic delegate declaration is as below:
delegate void Print<T> (T arg);
where void is again the return type and T in parentheses is generic argument type.
Now we already know the return-type and arguments type then why do we require extra Type in angle bracktes Print<T> ? What does it signify ?
Thank you all in advance.
The
<T>inPrint<T>is needed to tell the compiler that you are intending to create a generic method. Otherwise it could thinkTis some type, rather than a type parameter. While intuitively you can infer what the author meant, the compiler is more literal about it.