Last active
August 27, 2016 07:48
-
-
Save codingonHP/d5c3d3676273fd331e5a17731e823a26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { } | |
class Man Person { } | |
class Program | |
{ | |
// Define the delegate. | |
public delegate Person HandlerMethod(); | |
public delegate Person HandlerMehtod2(Man p); | |
public static Person PersonHandler() | |
{ | |
return null; | |
} | |
public static Man ManHandler() | |
{ | |
return null; | |
} | |
public static Man ManHandler2(Person person) | |
{ | |
return null; | |
} | |
static void Test() | |
{ | |
HandlerMethod handlerPerson = PersonHandler; | |
// Covariance enables this assignment. | |
HandlerMethod handlerMan = ManHandler; | |
//Contravariance enables this assignment. | |
HandlerMehtod2 handlerMehtod = ManHandler2; | |
ManHandler2(new Man()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment