Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use

(Class constructor method is also known as type constructor or type initializer) Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention.

A static constructor is used to initialize a class. It is called automatically to initialize the class before the first instance is created or any static members are referenced.

Share this article   |    Print    |    Article read by 1384 times
Author:
Guest
Guest user is that user who have done some activity on website without login. Activity contains commenting on any article, uploading an image on website etc.
Related Articles:
Related Interview Questions: