2007-05-25 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / tests / gtest-var-02.cs
blobc5179d94d63194643e11509c0a57d995e8e4c9e1
1 // Compiler options: -langversion:linq
2 // Tests variable type inference with the var keyword when assigning to user-defined types
3 using System;
5 public class Class1
7 public bool Method()
9 return true;
11 public int Property = 16;
14 public class Test
16 private class Class2
18 public bool Method()
20 return true;
22 public int Property = 42;
24 static int Main ()
26 var class1 = new Class1 ();
28 if (class1.GetType () != typeof (Class1))
29 return 1;
30 if (!class1.Method ())
31 return 2;
32 if (class1.Property != 16)
33 return 3;
35 var class2 = new Class2();
37 if (class2.GetType () != typeof (Class2))
38 return 4;
39 if (!class2.Method ())
40 return 5;
41 if (class2.Property != 42)
42 return 6;
44 return 0;