Pick random char

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

i have some chars:

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

now i\'m lookin

11条回答
  •  [愿得一人]
    2021-01-03 21:46

    You can try this :

     public static string GetPassword()
     {
    string Characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
     Random rnd = new Random();
    int index = rnd.Next(0,51);
    string char1 = Characters[index].ToString();
    return char1;
      }
    

    Now you can play with this code block as per your wish. Cheers!

提交回复
热议问题