C#建议邮箱输入验证

public static int emailduan(string x)//类里边,函数名随便起,需要传入参数为string类型
        {
            string[] a = x.Split('@');//以@为分界线,分为数组
            int a1 = a.Length;
            if (a1 == 2)
            {
                string[] b = a[1].Split('.');
                int b1 = b.Length;
                if (b1 == 2)
                {
                    if (b[1].Equals("com"))//判断字符串相等,返回true
                    { return 1; }
                    else { return 2; }
                }
                else { return 2; }
            }
            else { return 2; }
        }

posted on 2015-04-16 17:54  冰冥寒流  阅读(178)  评论(0编辑  收藏  举报