如何确定@字符和之间至少有两个字符.特点. [英] How do you make sure there are at least two characters between the @ character abd the . character.
本文介绍了如何确定@字符和之间至少有两个字符.特点.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何确保@字符和之间至少有两个字符.
How do you make sure there are at least two characters between the @ character abd the . character.
推荐答案
public static bool IsValidEmail(string email)
{
string[] sArray=email.Split('@');
string emailsplit=sArray[1];
string[] lastArray=emailsplit.Split('.');
return lastArray[0].Length > 2;
}
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;
}
}
}
这篇关于如何确定@字符和之间至少有两个字符.特点.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文