So, I have a delegate defined as:
public delegate void MyDelegate<T>(T myParameter);
Resharper suggests that I should make T contravariant as follows:
public delegate void MyDelegate<in T>(T myParameter);
Now itβs hard for me to understand why this is useful? I know that this is stopping me from making a T return type, but other than that, what other useful restrictions will I get by creating counterfeiting T ? That is, when it is time to use a delegate with an instance, which instances can I create using
public delegate void MyDelegate<T>(T myParameter);
which I cannot create with
public delegate void MyDelegate<in T>(T myParameter);
generics c # delegates variance
AxiomaticNexus
source share