close
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; }
        }
    }
 
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 imagefish 的頭像
    imagefish

    幻想魚的幻想空間

    imagefish 發表在 痞客邦 留言(0) 人氣()