2004-01-16 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / tests / gen-21.cs
1 using System;
2
3 class Foo<T>
4 {
5         T[] t;
6
7         public Foo (int n)
8         {
9                 t = new T [n];
10                 for (int i = 0; i < n; i++)
11                         t [i] = T.default;
12         }
13
14         public void Test ()
15         {
16                 X.Print (t [0]);
17         }
18 }
19
20 class Bar<T>
21 {
22         public void Test ()
23         {
24                 X.Print (X.default);
25                 X.Print (T.default);
26                 X.Print (S.default);
27         }
28 }
29
30 struct S
31 {
32         public readonly string Hello;
33
34         S (string hello)
35         {
36                 this.Hello = hello;
37         }
38
39         public override string ToString ()
40         {
41                 return String.Format ("S({0})", Hello);
42         }
43
44 }
45
46 class X
47 {
48         public static void Print (object obj)
49         {
50                 if (obj == null)
51                         Console.WriteLine ("NULL");
52                 else
53                         Console.WriteLine ("OBJECT: {0} {1}", obj, obj.GetType ());
54         }
55
56         static void Main ()
57         {
58                 Foo<string> a = new Foo<string> (4);
59                 a.Test ();
60
61                 Bar<int> b = new Bar<int> ();
62                 b.Test ();
63                 Bar<X> c = new Bar<X> ();
64                 c.Test ();
65         }
66 }