2010-04-03 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-28.cs
blobee1c7e5675745e113c0d702ab813a31f6f1e914c
1 using System.Collections;
2 abstract class A {
3 protected abstract int this [int a] { get; }
5 public int EmulateIndexer (int a)
7 return this [a];
11 class B : A {
12 protected override int this [int a] { get { return a;} }
14 public int M ()
16 return this [0];
20 class X {
21 int v1, v2;
23 int this [int a] {
24 get {
25 if (a == 0)
26 return v1;
27 else
28 return v2;
31 set {
32 if (a == 0)
33 v1 = value;
34 else
35 v2 = value;
39 static int Main ()
41 X x = new X ();
43 x [0] = 1;
44 if (x.v1 != 1)
45 return 1;
47 if (x [0] != 1)
48 return 2;
50 B bb = new B ();
52 if (bb.EmulateIndexer (10) != 10)
53 return 3;
56 // This tests that we properly set the return type for the setter
57 // use pattern in the following indexer (see bug 36156)
58 Hashtable a = new Hashtable ();
59 int b = (int) (a [0] = 1);
60 if (b != 1)
61 return 4;
62 return new B ().M ();