Use of static members with example using C#.NET.

Explain the use of static members with example using C#.NET.

- Static members are not associated with a particular instance of any class.

- They need to be qualified with the class name to be called.

- Since they are not associated with object instances, they do not have access to non-static members, it means that "this" cannot be used, which represents the current object instance.

- It is callable on a class even when no instance of the class has been created.

- Static member is always accessed by the class name, not instance name.

- Static methods and properties cannot access non-static fields and events in their containing type.

- They cannot access an instance variable of any object unless it is explicitly passed in a method parameter.

- Static members can be overloaded, but cannot overridden, because they belong to the class and not to any instance of the class.
How to achieve polymorphism in C#?
How to achieve polymorphism in C#.NET? - Polymorphism is when a class can be used as more than one type through inheritance....
Implementation inheritance and interface inheritance - C#.NET
What are implementation inheritance and interface inheritance? - Implementation inheritance is achieved when a class is derived from another class in such a way that it inherits all its members...
How to add a ReadOnly property in C#.NET
How to add a ReadOnly property in C#.NET? - Properties can be made read-only by having only a get accessor in the implementation...
Post your comment