//contraconvariance public static X_base incrA(X_base obj) { Y_child temp = new Y_child(); temp.val = obj.val + 10; return(temp); }
//convariance public static Y_child incrB(Y_child obj) { Y_child temp = new Y_child(); temp.val = obj.val + 1; return(temp); }
public static void tryContraVariance() { Y_child y = new Y_child(); changeIt ci = ContraVariance.incrA; y.val = 100; y.a = 500; Y_child Y = (Y_child)ci(y); Console.WriteLine(y.val); changeIt2 ci2 = ContraVariance.incrB; }