How can I randomly select one of three strings?

后端 未结 2 1121
你的背包
你的背包 2021-01-29 09:10

I have to create a password and I believe that I can do it, however I am stumped at the very beginning. I have 3 strings of characters, I would like to randomly select one of th

2条回答
  •  迷失自我
    2021-01-29 09:38

    The below code will help you generate a random number and then pick up the string at that position in the array

    string[] arr= {"qwertyuiopasdfghjklzxcvbnm","MNBVCXZLKJHGFDSAPOIUYTREWQ","1234567890"};
                   Random rnd = new Random();
                   int cnt = rnd.Next(2);
                   string r = arr[cnt];
    

提交回复
热议问题