Updated with review feedback.
[mono.git] / mcs / tests / test-209.cs
1 using System;
2
3 struct A
4 {
5         public readonly int i;
6
7         public A (int i)
8         {
9                 this.i = i;
10         }
11 }
12
13 class X
14 {
15         int i;
16
17         public int Foo {
18                 get {
19                         return 2 * i;
20                 }
21
22                 set {
23                         i = value;
24                 }
25         }
26
27         public int this [int a] {
28                 get {
29                         return (int) Foo;
30                 }
31
32                 set {
33                         Foo = a;
34                 }
35         }
36
37         public string this [string a] {
38                 set {
39                         Console.WriteLine (a);
40                 }
41         }
42
43         public string Bar {
44                 set {
45                         Console.WriteLine (value);
46                 }
47         }
48
49         public A A {
50                 get {
51                         return new A (5);
52                 }
53
54                 set {
55                         Console.WriteLine (value);
56                 }
57         }
58
59         public X (int i)
60         {
61                 this.i = i;
62         }
63
64         public static int Main ()
65         {
66                 X x = new X (9);
67                 int a = x.Foo = 16;
68                 int b = x [8] = 32;
69                 x ["Test"] = "Hello";
70                 x.Bar = "World";
71                 x.A = new A (9);
72                 // Compilation-only test.
73                 return 0;
74         }
75 }
76