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