What is static member of class?

A static member belongs to the class rather than to the instances of the class. In C# data fields, member functions, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member.
To access a static class member, use the name of the class instead of an instance variable
Static methods and Static properties can only access static fields and static events.

Like: int i = Car.GetWheels;
Here Car is class name and GetWheels is static property.

Static members are often used to represent data or calculations that do not change in response to object state.

2 comments:

  1. Static members are often used to represent data or calculations that do not change in response to object state....what does it mean??
    Can you provide any example??

    Thanks in Advance.
    Nidhi

    ReplyDelete
  2. WHAT IS ABSTRACT AND VIRTUAL CLASS?

    ReplyDelete

Type more interview question answer here