- Static modifier belongs to the type itself rather than specific object. This means a static member belongs to the class rather than the instance of the class. For example Console.WriteLine. There is no need to create an instance of Console to invoke WriteLine. And if that is done, the compiler complains.
- When is this used? This is implemented in case of utility classes where there is no need to implement object level state.
- Static modifier can be applied to -
- Method
- Property
- Constructor
- Class
Click on each link above for detailed working of each of them.
Click on each link above for detailed working of each of them.
- static keyword has a major role in Singleton Design Pattern. For better understanding of this pattern, one has to understand the working of this modifier thoroughly.
No comments:
Post a Comment