Class constructor = Static constructor
Instance constructor = Normal constructor
For example,
class MyClass
{
// Static/Class constructor.
// Note: Static constructors cannot have visibility modifier (eg. public/private),
// and cannot have any arguments.
static MyClass()
{
... // This will only execute once - when this class is first accessed.
}
// Normal/Instance Constructor.
public MyClass(...)
{
... // This will execute each time an object of this class is created.
}
}
So as an example, consider the following code:
static void Main(string[] args)
{
var a = new MyClass(); // Calls static constructor, then normal constructor.
a.DoSomething();
var b = new MyClass(); // Calls normal constructor only.
b.DoSomething();
}
Also, consider the following code:
static void Main(string[] args)
{
MyClass.SomeStaticMethod(); // Calls static constructor, then SomeStaticMethod().
MyClass.SomeOtherStaticMethod(); // Calls SomeOtherStaticMethod() only.
// Note: None of the above calls the normal constructor.
}