zoukankan      html  css  js  c++  java
  • C#中如何获取任意字母组合和验证邮件格式

        //产生随机任意字母长度组合
        public string RndNum1(int VcodeNum)
        {
            string Vchar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            string VNum = "";
            Random rand = new Random();
            for (int i = 0; i < VcodeNum; i++)
            {
                VNum += Vchar[rand.Next(Vchar.Length - 1)].ToString();
            }
            return VNum;

        }

        //返回:A46U-2VD4 形式的任意字母组合
        public string RndNum2(int VcodeNum)
        {
            string Vchar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            string VNum = "";
            Random rand = new Random();
            for (int i = 1; i <= VcodeNum; i++)
            {
                if (i % 8 == 0 && i != VcodeNum)
                {
                    VNum += Vchar[rand.Next(Vchar.Length - 1)].ToString() + "-";
                }
                else
                {
                    VNum += Vchar[rand.Next(Vchar.Length - 1)].ToString();
                }
            }
            return VNum;

        }

     //邮件格式是否正确
        public static bool isEmail(string inputEmail)
        {
            string strRegex = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
            Regex re = new Regex(strRegex);
            if (re.IsMatch(inputEmail))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

  • 相关阅读:
    angular js 自定义指令
    web api 解决跨域的问题
    angular 监听ngrepeat结束时间
    redis关闭和启动
    intellij idea快捷键
    mysql连接字符串
    crontab命令格式
    maven中scope属性的
    maven pom文件元素说明
    引入maven以外的jar包
  • 原文地址:https://www.cnblogs.com/nianshi/p/733974.html
Copyright © 2011-2022 走看看