如何使用c #windows应用程序在每年的每个月获取特定日期表单 [英] How to get particular Date form every Month in Year using c# windows application

查看:64
本文介绍了如何使用c #windows应用程序在每年的每个月获取特定日期表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家

如何使用c #windows应用程序获取每年每月的特定日期表单

How to get particular Date form every Month in Year using c# windows application

表示每隔5个日期月

我想每月5日下午5点插入数据

i want to insert data every 5th of month 5pm

最好的问候

HimaxNaz

推荐答案

以下代码将为您提供一年中每个月的第5个日期,对于这个问题我我使用
DateTime.Now 作为输入来确定要使用的年份:

The following code would give you the 5th date of every month of a year, for this question i am using the DateTime.Now as input to determine the year to be used :

List<DateTime> dates = new List<DateTime>();

for(int i=1; i<=12; i++)
{
   var date = new DateTime(DateTime.Now.Year,i,5);
   Console.WriteLine(date);
   dates.Add(date);
}

输出

请参阅以下工作演示:

DEMO Fiddle

希望有所帮助!

Hope it helps!


这篇关于如何使用c #windows应用程序在每年的每个月获取特定日期表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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