Jon Jagger
jon@jaggersoft.com
Table of Contents 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 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 17 Classesprevious at this levelnext at this level 17.2 Class membersprevious at this levelnext at this level 17.2.7 Reserved member namesprevious at this levelnext at this level 17.2.7.1 Member Names Reserved for Properties Paragraph 11 For a property P (§17.6) of type T, the following signatures are reserved:
T get_P();  
void set_P(T value);  
Paragraph 21 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:
123  
123  
456  
end example]
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS