blob: d64527b69329b479e82f2e4cfec20b40ea75c0a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Tests variable type inference with the var keyword when assigning to user-defined types
using System;
public class Class1
{
public bool Method()
{
return true;
}
public int Property = 16;
}
public class Test
{
private class Class2
{
public bool Method()
{
return true;
}
public int Property = 42;
}
public static int Main ()
{
var class1 = new Class1 ();
if (class1.GetType () != typeof (Class1))
return 1;
if (!class1.Method ())
return 2;
if (class1.Property != 16)
return 3;
var class2 = new Class2();
if (class2.GetType () != typeof (Class2))
return 4;
if (!class2.Method ())
return 5;
if (class2.Property != 42)
return 6;
return 0;
}
}
|