About Me

Hyderabad, Andhra Pradesh, India

Monday, July 11, 2011

Static Keyword

  1. A static method can access only static fields.
  2. A static method cannot access non-static fields.
  3. A static method cannot be called using object of a class.
  4. A static method can be called using Class name.
  5. Static fields can be used using Class Name.
A static method can access only static fields.


A static method cannot access non-static fields




Error Message



A static method cannot be called using an object of a class

Usually intellisense gives the list of method names available for a particular object. But here intellisense cannot show any user defined method.


A static method can be accessed using Class Name

Here Intellisense has the respective method name of the particular class.


Output



Static fields can be accessed using Class Name


Output

No comments:

Post a Comment