标签:blog ar sp div on log ad new as
public class Person {
public DateTime birth;
public DateTime? death;
string name;
public TimeSpan Age {
get {
if (!death.HasValue) {
return DateTime.Now - birth;
}
else {
return death.Value - birth;
}
}
}
//构造函数
public Person(string name, DateTime birth,DateTime?death) {
this.birth = birth;
this.death = death;
this.name = name;
}
}
Person tr = new Person("AAAA", new DateTime(1988, 12, 13),null);
Person kk = new Person("BBBB", new DateTime(1912, 12, 13), new DateTime(1954, 12, 12));
Console.ReadKey();
标签:blog ar sp div on log ad new as
原文地址:http://www.cnblogs.com/alphafly/p/4043468.html