C#时间差

DateTime d1 = DateTime.Parse("2012-3-10 10:30");
DateTime d2 = DateTime.Parse("2012-4-9 10:30");
System.TimeSpan nd = d2 - d1;

int num = nd.Minutes;
double num2 = nd.TotalMinutes;
Console.WriteLine(num.ToString());
Console.WriteLine(num2.ToString());
Console.WriteLine("小时:" + nd.TotalHours.ToString());
Console.WriteLine("天:" + nd.TotalDays.ToString());

posted @ 2012-07-02 14:10  要等闲阿  阅读(113)  评论(0编辑  收藏  举报