C#日期相减

   DateTime dt = Convert.ToDateTime(this.TextBox1.Text);
        DateTime de = Convert.ToDateTime(this.TextBox2.Text);
        System.TimeSpan ts = dt.Subtract(de);
        this.Label1.Text = "天" + ts.Days.ToString() + "小时" + ts.Hours.ToString() + "秒数" + ts.Minutes.ToString() + "毫秒" + ts.Seconds.ToString();
posted on 2008-05-24 11:34  freexiaoyu  阅读(2919)  评论(4编辑  收藏  举报