zoukankan      html  css  js  c++  java
  • 產生隨機數

      protected string CreateRandomCode(int codeCount)
        {
            string allChar = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,P,Q,R,S,T,U,W,X,Y,Z";
            string[] allCharArray = allChar.Split(',');
            string randomCode = "";
            int temp = -1;
            Random random = new Random();
            for (int i = 0; i < codeCount; i++)
            {
                if (temp != -1)
                {
                    random = new Random(i * temp * (int)DateTime.Now.Ticks);
                } int t = random.Next(23);
                if (temp == t)
                {
                    return CreateRandomCode(codeCount);
                }
                temp = t;
                randomCode += allCharArray[temp];
            }
            return randomCode;
        }
  • 相关阅读:
    DNS
    报文组成
    简单的转义字符
    普通字符
    正则表达式介绍
    Mybatis_HelloWorld
    Mybatis介绍
    基本概念
    EGit应用
    EGit
  • 原文地址:https://www.cnblogs.com/siri/p/2892036.html
Copyright © 2011-2022 走看看