Merge branch 'xml-fixes' of https://github.com/myeisha/mono into myeisha-xml-fixes
[mono-project.git] / mcs / docs / ecma334 / 10.7.1.1.xml
blob783a9cb12195220bcff953b9328fa195fed5217e
1 <?xml version="1.0"?>
2 <clause number="10.7.1.1" title="Hiding through nesting">
3   <paragraph>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. </paragraph>
4   <paragraph>
5     <example>[Example: In the example <code_example><![CDATA[
6 class A  
7 {  
8    int i = 0;  
9    void F() {  
10       int i = 1;  
11    }  
12    void G() {  
13       i = 1;  
14    }  
15 }  
16 ]]></code_example>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]</example>
17   </paragraph>
18   <paragraph>When a name in an inner scope hides a name in an outer scope, it hides all overloaded occurrences of that name. <example>[Example: In the example <code_example><![CDATA[
19 class Outer  
20 {  
21    static void F(int i) {}  
22    static void F(string s) {}  
23    class Inner  
24    {  
25       void G() {  
26          F(1);    // Invokes Outer.Inner.F  
27          F("Hello");  // Error  
28       }  
29       static void F(long l) {}  
30    }  
31 }  
32 ]]></code_example>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(&quot;Hello&quot;) results in a compile-time error. end example]</example> </paragraph>
33 </clause>