• 2022-10-29
    下面类的索引定义或使用正确的是()。
    A: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; }}}
    B: class MyClass{ int x; int y; public int this[int index] { set{ if (index==0) x=value; else y=value; }}}
    C: class MyClass{ int x; int y; public int INDEX[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}}
    D: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}}