using System;
class MyClass
{
int value0;
int value1;
public int this[int index]
{
get
{
return (0 == index) ? value0 : value1;
}
set
{
if (0 == index)
value0 = value;
else
value1 = value;
}
}
}
class MainClass
{
static void Main()
{
MyClass a = new MyClass();
Console.WriteLine("Values -- T0: {0}, T1: {1}", a[0], a[1]);
a[0] = 15;
a[1] = 20;
Console.WriteLine("Values -- T0: {0}, T1: {1}", a[0], a[1]);
}
}
|