Pick random char

前端 未结 11 1453
名媛妹妹
名媛妹妹 2021-01-03 20:57

i have some chars:

chars = \"$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&\".ToCharArray();

now i\'m lookin

11条回答
  •  走了就别回头了
    2021-01-03 21:37

    Instead of 26 please use size of your CHARS buffer.

    int num = random.Next(0, chars.Length)
    

    Then instead of

    let = (char)('a' + num)
    

    use

    let = chars[num]
    

提交回复
热议问题