What is difference between Private and Static Constructor?
sudhir kumar
Select an image from your device to upload
1)A static constructor is called before the first instance is created. i.e. global initializer.
Whereas Private constructor is called after the instance of the class is created.
2)Static constructor will be called first time when the class is referenced. Static constructor is used to initialize static members of the class.
Static members will not be initialized either by private or public constructor.
3)The static constructor will only be executed once.
The private constructor will be executed each time it is called.
1. Static constructor is called before the first instance of class is created, wheras private constructor is called after the first instance of class is created.
2. Static constructor will be executed only once, whereas private constructor is executed everytime, whenever it is called.