Musings
Public · Protected · Private
Covariance,Contravariance,compatibility
-
2012-08-07 10:25private void button2_Click(object sender, EventArgs e) { // compatibility. string str = "test"; object obj = str; IEnumerable<string> strings = new List<string>(); // Covariance. parent class can take derived class objects -- // reverse of object,string is not acceptable IEnumerable<object> objects = strings; Action<object> actionObj = ObjectWork; // Contravariance example .. notice reverse compatibility Action<string> actString = actionObj; } static void ObjectWork(object o) { }
This blog is frozen. No new comments or edits allowed.