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, I have a hard time understanding what this is good for? I know it prevents me from making T
a return type, but other than that, what useful constraints do I get by making T
contravariant? That is, when it's time to use the delegate with an instance, what instances can I create with
public delegate void MyDelegate<T>(T myParameter);
that I cannot create with
public delegate void MyDelegate<in T>(T myParameter);