When you do not declare any constructor, the class will call its default constructor which has a default public access modifier. The default constructor is a parameter less constructor which will be called by a class object.
Let's see an example of a Default Constructor -
public class Person
{
private int m_PersonID;
private string m_FirstName, m_LastName, m_City;
public Person()
{
m_PersonID = 19929;
m_FirstName = "No First Name";
m_LastName = "No Last Name";
m_City = "No City";
}
} |
This default constructor will be executed whenever the class is initialized – Person p = new Person();