Class level Variable scope

image_pdfimage_print

   

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/

namespace nsScope
{
    using System;
    public class Scope
    {
        int Var = 42;
        static public void Main ()
        {
            Scope cls = new Scope();
            int Var = 23;
            Console.WriteLine ("Class variable = " + cls.Var);
            Console.WriteLine ("Function variable = " + Var);
        }
    }
}