📜  随机字符串生成器 c# 代码示例

📅  最后修改于: 2022-03-11 14:49:10.580000             🧑  作者: Mango

代码示例5
private static Random random = new Random();
public static string RandomString(int length)
{
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
      .Select(s => s[random.Next(s.Length)]).ToArray());
}