当前位置:首页 > 通信资讯 > 正文

题目要求:

如何判断email地址是否合法(c#判断ip地址的合法性)

关键代码如下所示:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 class program { static void main(string[] args) { console.writeline("请输入正确的邮箱地址,以 @sina.com 结尾"); 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("正确"); } else { console.writeline("输入的邮箱地址有误"); } break; } console.readline(); } }

以上所述是小编给大家介绍的c#判断email地址是否为合法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!

原文链接:http://www.cnblogs.com/wintuzi/p/5687400.html

如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。