User Tools

Site Tools


notes:csharp:covariance_contravariance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
notes:csharp:covariance_contravariance [2020/01/21]
leszek [Contravariance]
notes:csharp:covariance_contravariance [2020/01/21] (current)
leszek [Delegate Type Variance]
Line 67: Line 67:
  
  
-===== Delegate ​Type Variance =====+===== Delegate Variance ===== 
 + 
 +==== Covariance ​====
  
-An example of covariance: ​ 
 <code csharp> <code csharp>
 using System.IO; using System.IO;
Line 98: Line 99:
 </​code>​ </​code>​
  
-An example of contravariance:​+==== Contravariance ====
  
 A single method //​MyMethod//​ that accepts //​EventArgs//​ is invoked by two different delegates, one passing a //​MouseEventArgs//​ and the other passing a //​KeyEventArgs//​. A single method //​MyMethod//​ that accepts //​EventArgs//​ is invoked by two different delegates, one passing a //​MouseEventArgs//​ and the other passing a //​KeyEventArgs//​.
notes/csharp/covariance_contravariance.txt · Last modified: 2020/01/21 by leszek