it was declared rather than to objects of class.
data fields,member functions,events,properties are
declared as static or non static.
static field example -
class TestClass
{
public static int first;
public static int second = 20;
}
Static member function example -
inside a c# class member functions can be defined
as static which can access only static members and
non static members by an instance of class.
class TestClass
{
private static int fi = 20;
private static int se = 40;
public static void Method()
{
Console.WriteLine("{0},{1}",fi,se);
}
}
class My{ public static void Main(){ My.Method(); }}
Static properties example -
class MyClass
{
public static int X
{
get{ Console.Write("GET");return 10; }
set{ Console.Write("SET"); }}
}