A non static class can have static as well as default constructor at the same time.
What is the difference between these two constructors? When shall I go for only static or static with default constructor?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Static constructor runs once per AppDomain just before you access the instance of class first time. You can use it to initialize static variables.
On the other hand default constructor runs every time you create new instance of the class. in default constructor you can initialize non-static fields of the instance.