Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you make sure there are at least two characters between the @ character abd the . character.
Posted
Comments
Nelek 8-Nov-12 19:24pm    
Please don't repost questions. With one time is enough.
c# email validation with if statement[^]

C#
public static bool IsValidEmail(string email)
        {
            string[] sArray=email.Split('@');
            string emailsplit=sArray[1];
            string[] lastArray=emailsplit.Split('.');

            return lastArray[0].Length > 2;
        }
 
Share this answer
 
C#
public static bool IsValidEmail(string strEmail)
        {
            bool result = true;

            if (strEmail.Length < 8)
            {
                result = false;
            }
            else if (!strEmail.Contains("@"))
            {
                result = false;
            }
            else if (strEmail.IndexOf("@") < 2)
            {
                result = false;
            }
            else if (!strEmail.Contains("."))
            {
                result = false;
            }
            else if (strEmail.IndexOf(".") < 6)
            {
                result = false;
            }
             else if (strEmail.IndexOf("."))
            {
                result = false;
            }
            else
            {
                result = true;
            }

            return result;
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900