[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tests / gtest-021.cs
blob16f4d6d86de11722af72432f64ee8043fb46973b
1 // Testing the default value expressions (14.5.13)
3 using System;
5 class Foo<T>
7 T[] t;
9 public Foo (int n)
11 t = new T [n];
12 for (int i = 0; i < n; i++)
13 t [i] = default (T);
16 public void Test ()
18 X.Print (t [0]);
22 class Bar<T>
24 public void Test ()
26 X.Print (default (X));
27 X.Print (default (T));
28 X.Print (default (S));
32 struct S
34 public readonly string Hello;
36 S (string hello)
38 this.Hello = hello;
41 public override string ToString ()
43 return String.Format ("S({0})", Hello);
48 class X
50 public static void Print (object obj)
52 if (obj == null)
53 Console.WriteLine ("NULL");
54 else
55 Console.WriteLine ("OBJECT: {0} {1}", obj, obj.GetType ());
58 public static void Main ()
60 Foo<string> a = new Foo<string> (4);
61 a.Test ();
63 Bar<int> b = new Bar<int> ();
64 b.Test ();
65 Bar<X> c = new Bar<X> ();
66 c.Test ();