[C#] 获取随机码, →→→→→进入此内容的聊天室

来自 , 2020-04-26, 写在 C#, 查看 129 次.
URL http://www.code666.cn/view/8bd39eae
  1. public static string GetRandomCode(int codeLength)
  2.         {
  3.             char[] codes = { '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y' };
  4.             string res="";
  5.             Random rd = new Random();
  6.             try
  7.             {
  8.                 for (int i = 0; i < 4; i++)
  9.                 {
  10.                     res+=(codes[rd.Next(0, codes.Length)]);
  11.                 }
  12.             }
  13.             catch (Exception ex)
  14.             {
  15.                 res=("fail" + ex.Message + ex.StackTrace);
  16.             }
  17.  
  18.             return res;
  19.         }

回复 "获取随机码,"

这儿你可以回复上面这条便签

captcha