我想在C#中获取两个日期之间的天数,该怎么做? [英] I wan to get number of days between two dates in C#, how to do that?

查看:77
本文介绍了我想在C#中获取两个日期之间的天数,该怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的datetimepicker1 = 2012年3月5日,datetimepicker2 = 2012年3月8日,以及如何获取3 ???
numberofDays = 3;

my datetimepicker1 = March 5, 2012 and datetimepicker2 = March 8, 2012 and how to obtain 3???

numberofDays=3;

推荐答案



看看DateTime.Subtract:

http://msdn.microsoft.com/de-de/library/8ysw4sby.aspx [^ ]



如果问题是英语,为什么来自菲律宾的OP会使用您的德语版本?我建议:

http://msdn.microsoft.com/library/8ysw4sby.aspx [
[END EDIT]

问候
Hi,

Have a look into DateTime.Subtract:

http://msdn.microsoft.com/de-de/library/8ysw4sby.aspx[^]



Why would OP, who is from Philippines, use your German version, if the question was in English? I would suggest this:

http://msdn.microsoft.com/library/8ysw4sby.aspx[^].

Also, it''s good to know that using the method through subtraction operator "-" is way more readable and clear.

[END EDIT]

Regards


这篇关于我想在C#中获取两个日期之间的天数,该怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆