日期:2014-05-17  浏览次数:20874 次

两者区别?什么是2.0写法,3.0写法
   class Program
    {
        static void Main(string[] args)
        {       
            //DateTime dt = Convert.ToDateTime("1990-12-08");//或者1990/12/08
            //UserInformation Uif = new UserInformation(01,"liu",dt);
            //Uif.UpdateAge();
            //Uif.Say(" 我来了!");
            //Console.ReadLine();
        }
}  
  class UserInformation
    {
        public UserInformation(int id, string username, DateTime birthday)
        {
            this.id = id;
            this.username = username;
            this.birthday = birthday;
        }
        private int id;
        private string username;
        private DateTime birthday;
        public int ID
        {
            set { id = value; }
            get { return id; }
        }
        public string UserName
        {
            set { username = value; }
            get { return username; }
        }
        public DateTime Birthday
        {
            set { birthday = value; }
            get { return birthday; }
        }

        public int Age = 0;
        public void UpdateAge()
        {
            Age = 1 + Int32.Parse(DateTime.Now.ToString("yyyy")) - Int32.Parse(birthday.ToString().Substring(0, 4));//birthday.Year
        }
        public string Say(string word)
        {