Friday, March 16, 2012

  1. You cannot use non static member of Class in the body of static Function. Why?
  2. Static Functions of Class only allow to use static member of Class in its body. Why?
  3. Static member can be accessible with the name of Class. Why?
  4. To access Static member, need not to create instance of Class. Why?
  5. Static Constructor gets call when very first instance of Class gets created. Why?
  6. Static Constructor not contains any parameterWhy?
  7. Any Class can contain max 1 static Constructor in it, Why?

Lets think in reverse way, Lets assume that non-static member are accessible in static function. 
We know there is Right Thumb Rule as Static function are accessible by their Class name itself, no need to create instance of Class to access them. 
In this case if we called Static function which contains non-static members in it, then Questions arise if no any instance has created; then how can non-static member get available inside Static function? I think no one have answer for this.
That means it is proved that "You cannot use non static member of Class in the body of static Function" 

Above explanation is enough to get answer of all above questions.