• 使用ChineseLunisolarCalendar 对象由年份获得生肖名,Datetime.now.tostring获得星期几


    一:使用ChineseLunisolarCalendar 对象由年份获得生肖名,截图

    二:代码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace GetShengXiao
    {
        public partial class Frm_Main : Form
        {
            public Frm_Main()
            {
                InitializeComponent();
            }
    
            private void btn_Get_Click(object sender, EventArgs e)
            {
                System.Globalization.ChineseLunisolarCalendar chinseCaleander =//创建日历对象ChineseLunisolarCalendar,将时间分成多个部分来表示,如分成年、月和日。 年按农历计算,而日和月按阴阳历计算。
                     new System.Globalization.ChineseLunisolarCalendar();
                string TreeYear = "鼠牛虎兔龙蛇马羊猴鸡狗猪";//创建字符串对象
                int intYear = chinseCaleander.GetSexagenaryYear(DateTime.Now);//计算年信息,GetSexagenaryYear计算与指定日期对应的甲子(60 年)循环中的年。
                string Tree = TreeYear.Substring(chinseCaleander.//得到生肖信息
                    GetTerrestrialBranch(intYear) - 1, 1);//GetTerrestrialBranch计算甲子(60 年)循环中指定年份的地支,
                //Substring(x,y)从此实例检索子字符串。 子字符串从指定的字符位置开始且具有指定的长度
                MessageBox.Show("今年是十二生肖" + Tree + "",//输出生肖信息
                    "判断十二生肖", MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
        }
    }

     三:now.tostring获得星期几,截图

    四:代码

    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 GetWeek
    {
        public partial class Frm_Main : Form
        {
            public Frm_Main()
            {
                InitializeComponent();
            }
    
            private void btn_GetWeek_Click(object sender, EventArgs e)
            {
                MessageBox.Show("今天是: "//显示星期信息
                    + DateTime.Now.ToString("dddd"), "提示!");//dddd是星期日,ddd是日,dd是01
            }
        }
    }
  • 相关阅读:
    那些你不知道的项目管理细节(四)—需求阶段的意识
    poj 3253 Fence Repair (STL优先队列)
    “大型票务系统”和“实物电商系统”在不能提供商品(服务)时给消费者带来的影响有巨大差异
    is和as在类型转换时的性能差异
    html5 5个重要特性
    xHTML与HTML的写法有什么不同?
    C++设计模式实现--訪问者(Visitor)模式
    开源,我的一些行动
    自写图片遮罩层放大功能jquery插件源代码,photobox.js 1.0版,不兼容IE6
    03004_SQL语句
  • 原文地址:https://www.cnblogs.com/hongmaju/p/3763452.html
Copyright © 2020-2023  润新知