Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0109 Implicit parameterless constructor

C# provides a parameterless constructor if the class has no constructor defined. The Rectangle in the following has no constructors and C# adds Rectangle() to it. using System; class Rectangle{ int Width; int Height; } class Program { static void Main(string[] args) { Rectangle r = new Rectangle(); } }