The accessible fields or properties can be called in a single statement to do the initialization.
using System;
class Rectangle{
public int Width;
public int Height;
}
class Program
{
static void Main(string[] args)
{
Rectangle r = new Rectangle { Width = 5, Height = 6 };
Console.WriteLine(r.Width);
}
}
| w___ww._j_a_va__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. |