using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace learning{ class Program { static void Main(string[] args) { student a = new student(); a.Birthday=Convert.ToDateTime("2014-1-1"); a.Name = "小明"; Console.WriteLine("我的姓名是{0}",a.Name); Console.WriteLine("我的性别是{0}", a.Sex); Console.WriteLine("我的生日是{0}", a.Birthday); Console.WriteLine("我的年龄是{0}", a.Age); Console.ReadKey(); } } class student { string name; public string Name { get { return name; } set { name = value; } } string sex = "男"; public string Sex { get { return sex; } } DateTime birthday; public DateTime Birthday { get { return birthday; } set { birthday = value; } } int age; public int Age { get { return age; } set { age = Convert.ToInt32(DateTime.Now.Year - Birthday.Year); } } }}
- 2 回答
- 0 关注
- 1452 浏览
添加回答
举报
0/150
提交
取消