Skip to content

Commit 60c360d

Browse files
Update cs0136.md (#46039)
* Update cs0136.md Update the cs0136 compile error to make more clear about the same name into and outside local block * Update docs/csharp/misc/cs0136.md --------- Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
1 parent 57dc53f commit 60c360d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

docs/csharp/misc/cs0136.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,28 @@ namespace MyNamespace
3434
}
3535
}
3636
}
37-
```
37+
```
38+
39+
The compiler reports this error regardless of the textual order of the variable declarations, as shown in the following example:
40+
41+
```csharp
42+
// CS0136.cs
43+
namespace MyNamespace
44+
{
45+
public class MyClass
46+
{
47+
public static void Main()
48+
{
49+
if (true)
50+
{
51+
int i = 1; // CS0136, hides i outside this block
52+
}
53+
int i = 0;
54+
i++;
55+
}
56+
}
57+
}
58+
```
3859

3960
From the [C# Language Specification](~/_csharpstandard/standard/basic-concepts.md#73-declarations):
4061

0 commit comments

Comments
 (0)