class Program
{
static void Main(string[] args)
{
// The demo of Object Initialize Set including old declaration and new declaration(C#3.0)
// If member access modifier isn't declared as "public", method_1 and method_2 isn't working.
// method_1
Contact contact = new Contact();
contact.LastName = "A-len";
contact.DateOfBirth = new DateTime(2012, 04, 03);
//method_2
Contact contactNew = new Contact
{
LastName = "A-len",
DateOfBirth = new DateTime(2012, 04, 03)
};
}
private class Contact
{
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
}
}
文章標籤
全站熱搜
