DateTime.IsLeapYear 方法判断是否是闰年,DaysInMonth判断一个月有几天,Addday取得前一天的日期GetYesterDay
2014-12-02 15:54
351 查看
一:DateTime.IsLeapYear 方法判断是否是闰年
二:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GetDays
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_Get_Click(object sender, EventArgs e)
{
if (DateTime.IsLeapYear(int.Parse(//判断是否为闰年,IsLeapYear返回bool指定的年份是否为闰年的指示
DateTime.Now.ToString("yyyy"))))
{
MessageBox.Show("本年有366天","提示!");//显示天数信息
}
else
{
MessageBox.Show("本年有365天", "提示!");//显示天数信息
}
}
}
}
三:DaysInMonth判断一个月有几天,截图
四:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DaysInMonth
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_Get_Click(object sender, EventArgs e)
{
int P_Count = DateTime.DaysInMonth(//获取本月的天数,返回指定年和月中的天数。
DateTime.Now.Year, DateTime.Now.Month);
MessageBox.Show("本月有" +//显示本月的天数
P_Count.ToString() + "天", "提示!");
}
}
}
五:Addday取得前一天的日期GetYesterDay,截图
六:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GetYesterDay
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_GetYesterday_Click(object sender, EventArgs e)
{
MessageBox.Show(//显示前一天日期
"昨天是:" + DateTime.Now.AddDays(-1).
ToString("yyyy年M月d日"), "提示!");
}
}
}
二:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GetDays
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_Get_Click(object sender, EventArgs e)
{
if (DateTime.IsLeapYear(int.Parse(//判断是否为闰年,IsLeapYear返回bool指定的年份是否为闰年的指示
DateTime.Now.ToString("yyyy"))))
{
MessageBox.Show("本年有366天","提示!");//显示天数信息
}
else
{
MessageBox.Show("本年有365天", "提示!");//显示天数信息
}
}
}
}
三:DaysInMonth判断一个月有几天,截图
四:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DaysInMonth
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_Get_Click(object sender, EventArgs e)
{
int P_Count = DateTime.DaysInMonth(//获取本月的天数,返回指定年和月中的天数。
DateTime.Now.Year, DateTime.Now.Month);
MessageBox.Show("本月有" +//显示本月的天数
P_Count.ToString() + "天", "提示!");
}
}
}
五:Addday取得前一天的日期GetYesterDay,截图
六:代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GetYesterDay
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
private void btn_GetYesterday_Click(object sender, EventArgs e)
{
MessageBox.Show(//显示前一天日期
"昨天是:" + DateTime.Now.AddDays(-1).
ToString("yyyy年M月d日"), "提示!");
}
}
}
相关文章推荐
- DateTime.IsLeapYear 方法判断是否是闰年,DaysInMonth判断一个月有几天,Addday取得前一天的日期GetYesterDay
- 编写程序方法boolean isLeap(int date),要求传入的的日期,能够输出该日期是否是闰年
- IsLeapYear、IsInLeapYear - 是否是闰年
- IsLeapYear、IsInLeapYear - 是否是闰年
- 判断year年份是否为闰年(能被4整除是闰年,能被整除100不是,能被400整除是闰年)。闰年leap_year为1,否则为0.
- 通常在C#中判断两个日期是否相等可使用DateTime的方法
- ECSHOP模板中用mod方法替代is div by方法来判断是否整除
- 内核中判断返回指针是否错误的方法:使用IS_ERR或者IS_ERR_OR_NULL
- IsValidDateTime、IsValidDate、IsValidTime、IsValidDateDay ... 判断时间是否合法
- java判断对象是否为数组 并且取得数组的值 --- 用instanceof或则isArray() 方法
- 判断日期是否合法的方法
- 判断TextBox中的内容是否为正确的日期的方法
- WeeksInAYear、WeeksInYear、DaysInAYear、DaysInAMonth、DaysInYear、DaysInMonth - 获取指定年月的周、日数
- js判断两个日期是否相等的方法
- 作业3(4)循环输入多个年份 year,判断该年是否为闰年。判断闰年的条件是:能被 4 整除但不能被100 整除,或者能被 400 整除。输入-1退出程序执行
- [C#]方法示例:判断是否闰年
- 【总结】DateTime日期类型格式化显示(转)以及判断输入文本框是否符合日期格式
- bool isLeapYear(int year)-判断年份是否为闰年的函数
- Oracle中判断日期是否合法 is_date 函数
- 如何用js判断两个文本框里的日期是否在同一个月里???