Constructors can have optional parameters as well.
using System;
class Rectangle {
public int Width;
public int Height;
public Rectangle(int w = 5, int h = 6){
Width = w;
Height = h;
}
}
class Program
{
static void Main(string[] args)
{
Rectangle r = new Rectangle();
Console.WriteLine(r.Width);
Console.WriteLine(r.Height);
}
}
The output:
5
6| www.j___a_v_a___2__s._c__o_m | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |