Difference between static and non static members?
c#
Solution
The `static` methods can by accessed directly from the class, while `non-static` methods (or instance methods as I like to call them) have to be accessed from an instance. That is why instatiating needs to be done for instance methods, while for static methods it's just not needed.
In OOP, `static variables` are used for values which cannot be stored by an instance variable. `static methods` cannot access instance methods or variables within a class. Of course that makes sense because that static method would not know which instance of the class we are trying to refer.
e.g. Supposed you wanted to keep a count of how many instances of a class exists? How would you store that in a single instance?
References:
- Static vs. Non-Static method in C#
- Static vs. non-static method
Problem
Possible Duplicate: What’s a static method in c#? I found it difficult to clear my mind about the actual concept of static and non-static(instance) members, after researching from so many forums i decided to put my question here: What is the difference between static and non static members?