你如何通过一年的每一天重复? [英] How do you iterate through every day of the year?

查看:145
本文介绍了你如何通过一年的每一天重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于1/1/2009开始日期和12/31/2009结束日期,我怎样才能通过每个迭代的日期,并使用C#检索DateTime值?

Given a start date of 1/1/2009 and an end date of 12/31/2009, how can I iterate through each date and retrieve a DateTime value using c#?

谢谢!

推荐答案

我会用一个循环,看起来像这样

I would use a loop that looks like this

for(DateTime date = begin; date <= end; date = date.AddDays(1))
{
}

设置开始和结束相应

Set begin and end accordingly

这篇关于你如何通过一年的每一天重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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