Scoping in C#. : Variable Scope : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Variable Scope »

 

Scoping in C#.








    
 


using System;

class MainClass {
    // Class level x variable
    static int x = 10;

    public static void Main() {
        // Locally defined copy of x
        int x = 5;
        int y = x;
        double z = y + 10.25;

        int a = (int)z;

        Console.WriteLine("X = {0} Y = {1} Z = {2}", x, y, z);
        Console.WriteLine("A = {0}", a);

        Console.WriteLine("Class Level X = {0}", MainClass.x);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Variable Scope