Determine if the mailbox format is correct

Source: Internet
Author: User

/Practice: Determine if the mailbox format is correct
1. There is only one @ contains @ indexof @=lastindexof
2. Cannot start with @ indexof! = 0
There is at least one after [email protected].
[email protected] and. Can't stay together.
5. Cannot end with.

Console.Write ("Please enter your e-mail address:"); strings =Console.ReadLine (); if(S.contains ("@")==true)//does it contain @            {                if(S.indexof ("@") !=0&&s.indexof ("@") ==s.lastindexof ("@") )//@ is not the beginning, only one @                {                    stringSS = S.substring (S.indexof ("@"));//intercept the string at the beginning of @                    if(SS. Contains (".")==true)//characters that contain.                    {                        if(SS. IndexOf (".")! =1&&ss. EndsWith (".")==false)//@ Heel. Do not stay together, and do not end with.{Console.WriteLine ("the mailbox you entered is in the correct format! "); }                        Else{Console.WriteLine ("the mailbox you entered is not formatted correctly"); }                    }                    Else{Console.WriteLine ("the mailbox you entered is not in the correct format! "); }                }                Else{Console.WriteLine ("the mailbox you entered is not formatted correctly"); }            }            Else{Console.WriteLine ("the mailbox you entered is not formatted correctly"); }

The second Kind
Console.Write ("Please enter your e-mail address:"); strings =Console.ReadLine (); BOOLx = S.contains ("@");//determine if there is a @ in the input character            intA = S.indexof ("@");//define first occurrence @ index number a            intb = S.lastindexof ("@");//define last occurrence @ index number B            stringSS = S.substring (a);//intercept the string at the beginning of @            BOOLy = ss. Contains (".");//determine if the SS contains.            intc = ss. IndexOf (".");//appears. Index number of the first time            BOOLz = ss. EndsWith (".");//Judging the end is not.            if(x = =true&& A = = b && y = =true&& C >1&& Z = =false) {Console.WriteLine ("the mailbox you entered is in the correct format! "); }            Else{Console.WriteLine ("The format of the mailbox you entered is incorrect! "); }

Determine if the mailbox format is correct

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.