Class level Variable scope : Variable Scope « Language Basics « C# / C Sharp






Class level Variable scope

Class level Variable scope
/*
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);
        }
    }
}

           
       








Related examples in the same category

1.Scoping in C#.
2.Scope class demonstrates instance and local variable scopes.Scope class demonstrates instance and local variable scopes.
3.method scope variable
4.System maximums and minimums.