CSharp examples for Custom Type:static
Static Members of a C# Class
using System;//from w w w .jav a 2 s . c o m class StaticVar { public static int num; public void count() { num++; } public int getNum() { return num; } } class MainClass { static void Main(string[] args) { StaticVar s1 = new StaticVar(); StaticVar s2 = new StaticVar(); s1.count(); s1.count(); s1.count(); s2.count(); s2.count(); s2.count(); Console.WriteLine("Variable num for s1: {0}", s1.getNum()); Console.WriteLine("Variable num for s2: {0}", s2.getNum()); } }