repl.it
@kironroy/

c_sharp_scope

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
main.cs
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
26
27
28
using System;

class MainClass {
  public static void Main (string[] args) {
    {
      byte a = 1;
      Console.WriteLine(a);
      // out of scope! Console.WriteLine(b);
      // out of scope! Console.WriteLine(c);
      {
        byte b = 2;
        Console.WriteLine(a);
        Console.WriteLine(b);
        // out of scope! Console.WriteLine(c);
        {
          Console.WriteLine("the most inner scope can log outer code blocks");
          byte c = 3;
          Console.WriteLine(a);
          Console.WriteLine(b);
          Console.WriteLine(c);

        }
        
      }
    
    }
  }
}