I was reading about Action Delegate on MSDN and so this under syntax
public delegate void Action<in T>(T obj);
Than I looked in c-sharpcorner.com and it used this syntax
public delegate void Action<T>(T obj);
As you can see there is no in before T.
Which syntax is right and what does that in mean?
EDIT: The same syntax used for Predicate.
Thanks.
The
inpart is for covariance and contravariance and was introduced in .NET 4.0, the article you link to was published in 2006 before .NET 4.0 was released (so obviously it doesn’t refer co[ntra]variance).