There are two types of constructor:Instance Constructor and Type Constructor(or so-called Static Constructor).c#
Instance Constructoride
When use the new key word to create an instance of class, it will do:this
Constructor is the only way to initialize a instance or a type, We may have seen codes like below:spa
class SomeClass { private int aField = 5; public SomeClass() { } }
you may think aField is initialized outside the constructor, but this is just a syntactic trick of c#。The compiler will gen some IL codes to set aField to 5 inside the constructor, AND, if there are more than one constructors, each one will contain that piece of IL initailling codes.code