In this part of the c sharp tutorial we will learn every minute concept about static keyword.
We use static keyword in order to make variable, class or function of type static
Static keyword when used ensures that only one instance is created
Static variable
single copy created and shared among all objects at the class level
Static class
A static class is created using the "static" keyword in C#
A C# static class is a class that can't be instantiated.
A static class can contain static members only.
Any class can have static constructor which is automatically called only once while first instantiation of a class
We can not call static constructor explicitly
Static members should be called with . operator
Static variables can be initialized outside the member function or class definition
NOTE: static class can not be inherited nor can be a child class
static constructor is called only once on first initialization of class
コメント