#region 根据月份来确定每月的最大天数
//月份为两位
private int SetDate(string time)
{
int intYear;
int intMonth;
int intDay;
string year = time.Substring(0,4);
string month = time.Substring(4,2);
int.TryParse(year, out intYear);
int.TryParse(month, out intMonth);
if (intMonth == 02)
{
if (intYear % 400 == 0 || (intYear % 4 == 0 && intYear % 100 != 0))//判断是不是闰年
{
intDay = 29;
}
else
{
intDay = 28;
}
}
switch (intMonth)
{
case 04:
case 06:
case 09:
case 11: intDay = 30; break;
default: intDay = 31; break;
}
return intDay;
}
#endregion
C# 根据月份来确定每月的最大天数
最新推荐文章于 2025-11-30 12:02:36 发布
本文详细介绍了如何通过编程方式根据给定月份确定其最大可能天数,包括判断闰年的逻辑,并通过switch-case结构实现不同月份的最大天数计算。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Stable-Diffusion-3.5
图片生成
Stable-Diffusion
Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率
1216

被折叠的 条评论
为什么被折叠?



