what is Co-Varient and Contravarient in C#
what is Co-Varient and Contravarient in C#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sumit JoshiPosted Sep 28, 2015, 1:28 AM
// Assignment compatibility.// An object of a more derived type is assigned to an object of a less derived type.object obj = str;// Covariance.// An object that is instantiated with a more derived type argument// is assigned to an object instantiated with a less derived type argument./ Contravariance.// Assume that the following method is in the class:// static void SetObject(object o) { }Action<object> actObject = SetObject;// An object that is instantiated with a less derived type argument// is assigned to an object instantiated with a more derived type argument.// Assignment compatibility is reversed.Action<string> actString = actObject;Siddarth PathakPosted Sep 25, 2015, 2:10 AM
Sumit JoshiPosted Sep 24, 2015, 2:58 PM
Francis SusaimichaelPosted Sep 24, 2015, 5:52 AM
Munesh SharmaPosted Sep 24, 2015, 2:46 AM