Wednesday, 22 November 2017

Difference Between Static Constructor and private constructor


a.) The static constructor will only be executed once while the private constructor will be executed each time it is called.
b. ) The static constructor cannot have parameters but The private Constructor may have parameters
c.) A static constructor is called before the first instance is created. So it’s kind of global initialize.
    Private constructor is called after the instance of the class is created.
d.) A class can have only one static constructor but a class can have multiple private constructors.
e.) Static constructor can not be overloaded but private constructor can be.

No comments:

Post a Comment