ECMA-334 C# Language Specification17.2.7.1: Member Names Reserved for Properties |
For a property P (17.6) of type T, the following signatures are reserved:
T get_P();
void set_P(T value);
|
Both signatures are reserved, even if the property is read-only or write-only.
[Example: In the example
using System;
class A {
public int P {
get { return 123; }
}
}
class B: A {
new public int get_P() {
return 456;
}
new public void set_P(int value) {
}
}
class Test
{
static void Main() {
B b = new B();
A a = b;
Console.WriteLine(a.P);
Console.WriteLine(b.P);
Console.WriteLine(b.get_P());
}
}
|
a class A defines a read-only property P, thus reserving signatures for get_P and set_P methods. A class B derives from A and hides both of these reserved signatures. The example produces the output: end example]