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 14 Expressionsprevious at this levelnext at this level 14.5 Primary expressionsprevious at this levelnext at this level 14.5.4 Member accessprevious at this levelnext at this level 14.5.4.1 Identical simple names and type names Paragraph 11 In a member access of the form E.I, if E is a single identifier, and if the meaning of E as a simple-name (§14.5.2) is a constant, field, property, local variable, or parameter with the same type as the meaning of E as a type-name (§10.8), then both possible meanings of E are permitted. 2 The two possible meanings of E.I are never ambiguous, since I must necessarily be a member of the type E in both cases. 3 In other words, the rule simply permits access to the static members of E where a compile-time error would otherwise have occurred. [Example: For example:
struct Color  
{  
   public static readonly Color White = new Color(...);  
   public static readonly Color Black = new Color(...);  
   public Color Complement() {...}  
}  
class A  
{  
   public Color Color;          // Field Color of type Color  
   void F() {  
      Color = Color.Black;       // References Color.Black static member  
      
      Color = Color.Complement();  // Invokes Complement() on Color field  
      
   }  
   static void G() {  
      Color c = Color.White;    // References Color.White static member  
      
   }  
}  
Within the A class, those occurrences of the Color identifier that reference the Color type are underlined, and those that reference the Color field are not underlined. end example]
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS