cleol
[mcs.git] / tests / test-23.cs
blob0723c667d95ef96a5ff9e7ae746dc33a763bbfc3
1 //
2 // Tests properties
3 //
4 using System;
6 class X {
7 static int v;
9 static X ()
11 v = 10;
14 public static int Value {
15 get {
16 return v;
19 set {
20 v = value;
24 static int Main ()
26 if (Value != 10)
27 return 1;
29 Value = 4;
31 if (Value != 4)
32 return 2;
34 Y y = new Y ("hello");
36 if (y.Value != "hello")
37 return 3;
39 y.Value = "goodbye";
40 if (y.Value != "goodbye")
41 return 4;
43 Z z = new Z ();
45 if (Z.IVal != 4)
46 return 5;
47 Z.IVal = 10;
48 if (Z.IVal != 10)
49 return 6;
51 z.XVal = 23;
52 if (z.XVal != 23)
53 return 7;
55 return 0;
59 class Y {
60 string init;
62 public Y (string s)
64 init = s;
67 public string Value {
68 get {
69 return init;
72 set {
73 init = value;
78 struct Z {
79 static int val;
80 int xval;
82 static Z ()
84 val = 4;
87 static public int IVal {
88 get {
89 return val;
92 set {
93 val= value;
97 public int XVal {
98 get {
99 return xval;
102 set {
103 xval = value;