📜  c# 随机字符串 - C# 代码示例

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

代码示例3
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());
}