Samir Bhogayta
Assume that a class, Class1, has both instance and static constructors. Given the code below, how many times will the static and instance constructors fire?
By Samir Bhogayta in C# on Jun 25 2016
  • Samir Bhogayta
    Jun, 2016 25

    Class1 c1 = new Class1(); Class1 c2 = new Class1(); Class1 c3 = new Class1();By definition, a static constructor is fired only once when the class is loaded. An instance constructor on the other hand is fired each time the class is instantiated. So, in the code given above, the static constructor will fire once and the instance constructor will fire three times.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS