本文介绍了如何计算C#中文本框中两个日期之间的差异。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框,我在其中存储来自日历的日期。我有第三个文本框,我想在c#中计算两个日期之间的差异后存储天数。

我该怎么做? Plz帮助。



谢谢。

I have two textboxes in which I am storing dates from calender. I have a third textbox in which I want to store the number of days after calculating the difference between the two dates in c#.
How can I do that? Plz help.

Thank you.

推荐答案


DateTime d1=DateTime.MinValue;
DateTime d2=DateTime.MaxValue;
TimeSpan span=d2-d1;
Console.WriteLine( "There're {0} days between {1} and {2}" , span.TotalDays, d1.ToString(), d2.ToString() );



这篇关于如何计算C#中文本框中两个日期之间的差异。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 01:28