Instance 365 (4) --------- use the ChineseLunisolarCalendar object to obtain the Zodiac name from the year, Datetime. now. tostring to get the day of the week

Source: Internet
Author: User

I. Use the ChineseLunisolarCalendar object to obtain the Chinese zodiac name from the year,

Ii. Code
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 = // create a Calendar Object (Chinese) LunisolarCalendar divides time into multiple parts, such as year, month, and day. Year is calculated based on the lunar calendar, while day and month are calculated based on the lunar calendar. New System. globalization. chineseLunisolarCalendar (); string TreeYear = "rat, ox, Tiger, Rabbit, dragon, Snake, horse, monkey, chicken, dog, and pig"; // create a string object int intYear = chinseCaleander. getSexagenaryYear (DateTime. now); // calculate the year information. GetSexagenaryYear calculates the year in the cycle (60 years) corresponding to the specified date. String Tree = TreeYear. substring (chinseCaleander. // obtain the Zodiac information GetTerrestrialBranch (intYear)-1, 1); // GetTerrestrialBranch calculates the geographic branch of the specified year in the (60 years) cycle, // Substring (x, y) retrieve the substring from this instance. The substring starts from the specified character position and has the specified length MessageBox. show ("this year is the Zodiac" + Tree + "year", // output the Zodiac information "judge the Zodiac", MessageBoxButtons. OK, MessageBoxIcon. information );}}}
3. now. tostring obtains the day of the week,

4. Code
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 ("today is:" // display the week information + DateTime. now. toString ("dddd ")," Prompt! "); // Dddd is Sunday, ddd is day, dd is 01 }}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.