Hi..!! i have created a Customer Details form in C# asking detail about customer...One of its field asks for customer email.. Please tell me how to validate a email id..Thnx..!!

for this you have to use RegularExpression class in this there is Regex class. for email vallidation see this code.
using System.Text.RegularExpressions;

public bool IsValidEmailAddress(string EmailAddress)
Regex regEmail = new Regex(@"^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
if(regEmail.IsMatch(EmailAddress))  ///in Email address write user email address
return true;
return false;


string pattern=@"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" +@"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" + @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
System.Text.RegularExpressions.Match match = Regex.Match(txtEmail.Text.Trim(), pattern, RegexOptions.IgnoreCase);


try it works after this mark this thread as solved

Read the rules

don't apologize to me, it's OP's learning experience you took away, it's called no pain no gain.

If he took the effort in trying to figure it out he would learn it, copy paste ensures he just gets done.

for what purpose this regular expression is used ^[a-zA-Z0-9]+([_.-]?[a-zA-Z0-9]+)?@[a-zA-Z0-9]+([_-]?[a-zA-Z0-9]+)*([.]{1})[a-zA-Z0-9]+([.]?[a-zA-Z0-9]+)*$

This question has already been answered. Start a new discussion instead.