blob: 50f7dbb02bf03d08d427dbee60da9280a2f46538 (
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
47
48
49
50
51
52
53
54
55
56
|
abstract class A {
protected abstract int this [int a] { get; }
public int EmulateIndexer (int a)
{
return this [a];
}
}
class B : A {
protected override int this [int a] { get { return a;} }
public int M ()
{
return this [0];
}
}
class X {
int v1, v2;
int this [int a] {
get {
if (a == 0)
return v1;
else
return v2;
}
set {
if (a == 0)
v1 = value;
else
v2 = value;
}
}
static int Main ()
{
X x = new X ();
x [0] = 1;
if (x.v1 != 1)
return 1;
if (x [0] != 1)
return 2;
B bb = new B ();
if (bb.EmulateIndexer (10) != 10)
return 3;
return new B ().M ();
}
}
|