Exercise: C #---Class (Social Security number intercepts birthdays, validates mailboxes, DateTime)

Source: Internet
Author: User

//Exercise 1: Capturing birthdaysConsole.Write ("Please enter your ID number:"); stringID =Console.ReadLine (); Console.WriteLine ("your birthday is:"+ ID. Substring (6,4) +"years"+ ID. Substring (Ten,2) +"Month"+ ID. Substring ( A,2) +"Day"); Console.ReadLine (); 

  /** Exercise 2: Determine if the mailbox format is correct * Analysis: * 1, have and can only have one @ * 2, cannot start with @ 3, cannot. End             * 4, @ and. You can't lean together at least one at a. */Console.Write ("Please enter your email account:"); stringMail =Console.ReadLine (); if(Mail. Contains ("@"))            {                intaa = mail. IndexOf ("@"); intbb = mail. LastIndexOf ("@"); if(AA = =BB) {                    BOOLA = mail. StartsWith ("@"); if(!a) {stringSS =Mail.                        Substring (AA); if(SS. Contains ("."))                        {                            intDian = ss. IndexOf ("."); if(Dian! =1)                            {                                intHOU = ss. LastIndexOf ("."); if(Hou! = ss. Length-1) {Console.WriteLine ("the format of the input mailbox is correct! "); }                                Else{Console.WriteLine ("wrong input! "); }                            }                            Else{Console.WriteLine ("wrong input! "); }                        }                        Else{Console.WriteLine ("wrong input! "); }                    }                    Else{Console.WriteLine ("wrong input! "); }                }                Else{Console.WriteLine ("wrong input! "); }            }            Else{Console.WriteLine ("wrong input! "); } console.readline ();

//Exercise 3: Get the current time, add n days to print out the day of the weekDateTime date =NewDateTime (); Date=DateTime.Now; DayOfWeek Day=date.            DayOfWeek; Console.WriteLine ("The current time is:"+ Date +"\ t"+Day ); Console.Write ("Please enter the number of days to increase:"); intn=int.            Parse (Console.ReadLine ()); DateTime Date1=NewDateTime (); Date1=date.            AddDays (n); DayOfWeek Day1=Date1.            DayOfWeek; Console.WriteLine ("Increase"+ N +"days later, the time is:"+ Date1 +"\ t"+day1); Console.ReadLine ();

Exercise: C #---Class (Social Security number intercepts birthdays, validates mailboxes, DateTime)

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.