C # To determine whether an email address is a legal _c# tutorial

Source: Internet
Author: User
Tags readline

Topic Requirements:

The key code looks like this:

Class program
{
static void Main (string[] args)
{
Console.WriteLine ("Please enter the correct email address to @sina. com end");
String US =convert.tostring (Console.ReadLine ());
String str1 = us. Replace ("@", "");
int count = us. Length-str1. Length;
String str2 = us. Replace (".", "");
int count2 = us. Length-str2. Length;
int count3 = us. Length-1;
int Xl=us. IndexOf (".") -us. IndexOf ("@");
bool MW = (US. IndexOf ("@sina. com") = = (US. Length-9));
while (count = = 1 && count2 = 1 && us. IndexOf ("@") > 0 && us. IndexOf (".") > us. IndexOf ("@") 
&& us. IndexOf (".") <count3)
{
if (XL!= 1 && us. Contains ("@sina. com") && MW)
{
Console.WriteLine ("correct");
}
else {
Console.WriteLine ("Entered a wrong mailbox address");
}
break;
Console.ReadLine ();
}

The above mentioned is small set to introduce C # to judge email address is legitimate, I hope to help you, if you have any questions please give me a message, small set will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.