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();
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.