3 interface IContravariant
<in T
>
7 interface ICovariant
<out T
>
13 public static bool Contra
<T
> (IContravariant
<T
> e1
, IContravariant
<T
> e2
)
15 Console
.WriteLine (typeof (T
));
16 return typeof (T
) == typeof (string);
19 public static bool Covariant
<T
> (ICovariant
<T
> e1
, ICovariant
<T
> e2
)
21 Console
.WriteLine (typeof (T
));
22 return typeof (T
) == typeof (object);
25 public static bool CovContCont
<T
> (ICovariant
<T
> e1
, IContravariant
<T
> e2
, IContravariant
<T
> e3
)
27 Console
.WriteLine (typeof (T
));
28 return typeof (T
) == typeof (string);
31 public static bool ContCovContCov
<T
> (IContravariant
<T
> e1
, ICovariant
<T
> e2
, IContravariant
<T
> e3
, ICovariant
<T
> e4
)
33 Console
.WriteLine (typeof (T
));
34 return typeof (T
) == typeof (string);
37 public static bool CovCovCont
<T
> (ICovariant
<T
> e1
, ICovariant
<T
> e2
, IContravariant
<T
> e3
)
39 Console
.WriteLine (typeof (T
));
40 return typeof (T
) == typeof (string);
43 public static int Main ()
46 ICovariant
<object> a
= null;
47 ICovariant
<string> b
= null;
48 if (!Covariant (a
, b
))
51 IContravariant
<string> a_1
= null;
52 IContravariant
<object> b_1
= null;
53 if (!Contra (a_1
, b_1
))
56 ICovariant
<string> a_2
= null;
57 IContravariant
<object> b_2
= null;
58 IContravariant
<string> c_2
= null;
59 if (!CovContCont (a_2
, b_2
, c_2
))
62 IContravariant
<object> a_3
= null;
63 ICovariant
<string> b_3
= null;
64 IContravariant
<string> c_3
= null;
65 ICovariant
<string> d_3
= null;
66 if (!ContCovContCov (a_3
, b_3
, c_3
, d_3
))
69 Console
.WriteLine ("ok");