What is Static keyword in C#
Example of static keyword
“Static” keyword can be used for declaring a static member.The keyword Static can be applied to the Classes, field, method, properties, operator, event and constructors. Methods and variable which we use as static doesn't need an instance to be created of a class.
Example of static keyword
class testclass
{
public static int statint;
public static void squareroot();
}
we can call the above static method and variable without creating the instance of the class
How to call a static method
testclass.squareroot();
apart from this the static method can use only the static variables of same class.
Comments
Post a Comment