C# – Static
C# includes static
keyword just like other programming languages such as C++, Java, etc. The static
keyword can be applied on classes, variables, methods, properties, operators, events and constructors. However, it cannot be used with indexers, destructors or types other than classes.
The static
modifier makes an item non-instantiable, it means the static item cannot be instantiated.
If the static modifier is applied to a class then that class cannot be instantiated using the new
keyword.
If the static modifier is applied to a variable, method or property of class then they can be accessed without creating an object of the class, just use className.propertyName, className.methodName.