Monday, November 28, 2011

Static methods in csharp

A method declaring using the static keyword is a static method rest of all instance only.While defining static methods,we should not refer to any instance member of class directly,but we can use them by creating the object of the class.Non static members of a class cannot be referred from static blocks with out object reference.
class example
 int x=10;
 static int y=20;
 static void add()
    example e=new example();

No comments: