the C# compiler requires a class have a constructor, you don't *have* to use it or even type one if you don't need it. The C# compiler will add a blank constructor with no parameters at compile time if you don't type any constructor. Constructors are good for initialising classes to a certain minimum state of readyness if you like, it is dependant on your project and what you are implementing.
You can have more than one constructor, all must have different signatures (different parameter lists) this allows consumers of your class to instantiate an instance of it in different states again this depends on how complex a class you are creating and the problem you are trying to solve.
To add to that...
Think of constructors as quite literally that: A method that constructs the class's insides when it is instantiated.
When a class is first called
ClassA myClass = new ClassA();
the very first thing the compiler does is run the constructor.
What I use them for is to setup my fields and what-not so that everything is ready when I need it. Here is an example...
Class A
{
private string _myField;
public A()
{
_myField = "Called Constructor!";
MessageBox.Show(_myField.ToString());
}
}
When you instiantate the class as I showed above (Class A myClass = new Class A) it will print out "Called Constructor!" when you run it!
What hollystyles is talking about when they mention having more than one constructor …