How is it possible that class in C# may has no constructors defined? For instance I have a class
internal class TextStyle
{
internal string text = "";
internal Font font = new Font("Arial", 8);
internal Color color = Color.Black;
}
And in the code this class is instantiated as
TextStyle textParameters = new TextStyle();
If you don't declare any constructors for a non-static class, the compiler provides a public (or protected for abstract classes) parameterless constructor for you. Your class effectively has a constructor of:
This is described in section 10.11.4 of the C# 4 spec:
The only classes in C# which don't have any instance constructors are static classes, and they can't have constructors.