zoukankan      html  css  js  c++  java
  • c# .Net随机生成字符串代码

    /// <summary>
            /// 随机生成字符串
            /// </summary>
            /// <param name="OperationType">数字字母组合:NUMBERLETTER 数字:NUMBER  大小写组合字母:ALLLETTER 大写字母:UPLETTER 小写字母:LOWLETTER</param>
            /// <param name="Length">位数</param>
            /// <returns></returns>
            public static string CharM(string OperationType, int Length)
            {
                string chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                switch (OperationType)
                {
                    case "NUMBERLETTER"://全字符模式
                        chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                        break;
                    case "NUMBER"://数字模式
                        chars = "0123456789";
                        break;
                    case "ALLLETTER"://大小写字母模式
                        chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                        break;
                    case "UPLETTER"://大写字母模式
                        chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                        break;
                    case "LOWLETTER"://小写字母模式
                        chars = "abcdefghijklmnopqrstuvwxyz";
                        break;             
                }
                Random randrom = new Random((int)DateTime.Now.Ticks);
    
                string str = "";
                for (int i = 0; i < Length; i++)
                {
                    str += chars[randrom.Next(chars.Length)];
                }          
                return str;
            }

    生成随机字符串,字符组合等...

  • 相关阅读:
    ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
    pycocotools使用教程
    with torch.no_grad() 详解
    虚拟机Ubuntu上下载Pytorch显示超时
    Deep Layer Aggregation DLA网络的结构
    tgz文件解压命令
    install mysql at linux
    devops issue
    process data
    unittest
  • 原文地址:https://www.cnblogs.com/innershare/p/10593803.html
Copyright © 2011-2022 走看看