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 10 Basic conceptsprevious at this levelnext at this level 10.7 Scopesprevious at this levelnext at this level 10.7.1 Name hidingprevious at this levelnext at this level 10.7.1.1 Hiding through nesting Paragraph 11 Name hiding through nesting can occur as a result of nesting namespaces or types within namespaces, as a result of nesting types within classes or structs, and as a result of parameter and local variable declarations. [Example: In the example
class A  
{  
   int i = 0;  
   void F() {  
      int i = 1;  
   }  
   void G() {  
      i = 1;  
   }  
}  
within the F method, the instance variable i is hidden by the local variable i, but within the G method, i still refers to the instance variable. end example]
Paragraph 21 When a name in an inner scope hides a name in an outer scope, it hides all overloaded occurrences of that name. [Example: In the example
class Outer  
{  
   static void F(int i) {}  
   static void F(string s) {}  
   class Inner  
   {  
      void G() {  
         F(1);    // Invokes Outer.Inner.F  
         F("Hello");  // Error  
      }  
      static void F(long l) {}  
   }  
}  
the call F(1) invokes the F declared in Inner because all outer occurrences of F are hidden by the inner declaration. For the same reason, the call F("Hello") results in a compile-time error. end example]
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS