add ISafeSerializationData
[mcs.git] / tests / gtest-054.cs
blob7080a2d417a3fb8e9307e0a0e0331df671556e48
1 //
2 // Conversions involving type parameters (26.7.4).
3 // This is a compilation-only test since some of the explict
4 // conversions would trigger an InvalidCastException.
5 //
7 using System;
9 interface Foo
11 void Hello ();
14 class A
15 { }
17 class B : A, Foo
19 public void Hello ()
20 { }
22 public static implicit operator C (B b)
24 return new C ();
28 class C
30 public static explicit operator B (C c)
32 return new B ();
36 class Test
38 static void Simple<T> (T t)
40 object o = t;
41 t = (T) o;
42 Foo foo = (Foo) t;
43 t = (T) foo;
46 static void Interface<T> (T t)
47 where T : Foo
49 Foo foo = t;
52 static void Class<T> (T t)
53 where T : B
55 B b = t;
56 A a = t;
57 Foo foo = t;
58 t = (T) b;
59 t = (T) a;
60 t = (T) foo;
61 C c = t;
62 t = (T) c;
65 static void Array<T> (T[] t)
67 object o = t;
68 Array a = t;
69 t = (T []) o;
70 t = (T []) a;
73 static void Main ()
74 { }