zoukankan      html  css  js  c++  java
  • DateTime.IsLeapYear 方法判断是否是闰年,DaysInMonth判断一个月有几天,Addday取得前一天的日期GetYesterDay

    一: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日"), "提示!");

            }

        }

    }

    佛为心,道为骨,儒为表,大度看世界; 技在手,能在身,思在脑,从容过生活; 三千年读史,不外功名利禄; 九万里悟道,终归诗酒田园;
  • 相关阅读:
    深度学习优化方法比较
    调参
    Numpy/Pytorch之数据类型与强制转换
    numpy:维度问题
    js模板引擎-juicer
    js模板引擎-腾讯artTemplate 简洁语法例子
    canva绘制时钟
    js中的break ,continue, return
    JavaScript奇技淫巧44招
    数据类型
  • 原文地址:https://www.cnblogs.com/taofx/p/4137665.html
Copyright © 2011-2022 走看看