Sunday, 11 October 2015

Scope of a variable in C#

using System;
class Program
{
    static int X = 10;
    // X is called as a global/ class level variable

    public static void Main()
    {
        int y = 25;
        string s = "India";
        //y and s are called local /method level variable

        Console.WriteLine(X);
        Console.WriteLine(y);
        Console.WriteLine(s);
    }
}

No comments:

Post a Comment