_14__enum Day of the week

Source: Internet
Author: User

classenumapp{//declares an enumeration type weekday, the base class is int, and the access scope is public     Public enumWeekday {Sun, Mon, Tue, Wed, Thu, Fri, Sat} Public Static voidMain () {//declaring a variable with an enumeration type weekday and assigning an initial valueWeekday WD1 =Weekday.mon; Console.WriteLine ("Weekly working days starting with {0}", WD1); Weekday WD2=Weekday.fri; Console.WriteLine ("end to {0}", WD2); //enumeration Type variables are used to calculateConsole.WriteLine ("{0} business days per week", wd2-wd1);        Console.WriteLine (); //enum type variables as arguments to functionsConsole.WriteLine ("after Mon is {0}", NextDay (Weekday.mon));                Console.WriteLine (); //using the enumeration type's GetNames () method        foreach(stringS1inchWeekday.getnames (typeof(Weekday))) {Console.Write (S1+" "); } Console.WriteLine ("\ n"); //to read the value of an enumeration type variable from the command lineConsole.Write ("What's the day of the week?"); Weekday WD3= (Weekday) weekday.parse (typeof(Weekday), Console.ReadLine ()); Console.WriteLine ("tomorrow is {0}", NextDay (WD3));                Console.WriteLine (); //comparing values of enumerated typesConsole.Write ("What 's the day of physical education?"); WD1= (Weekday) weekday.parse (typeof(Weekday), Console.ReadLine ()); Console.Write ("physical test on the day of the week?"); WD2= (Weekday) weekday.parse (typeof(Weekday), Console.ReadLine ()); if(Wd1.compareto (wd2) = =0) {Console.WriteLine ("bad, on the same day. "); }        Else{Console.WriteLine ("No , it's not the same day."); }    }        //function: Get the next day (days of the week)//Parameters://WD: Enum type weekday//return value: Enum type weekday     Public StaticWeekday NextDay (Weekday wd) {Weekday wdnext; if(WD = =Weekday.sat) {Wdnext=Weekday.sun; }        Else{Wdnext=wd+1; }        returnWdnext; }}

_14__enum Day of the week

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.