Generate key?

Whenever you want to do something random, you will pretty much always be using the Random class. You create a single instance and then call the appropriate method(s) one or more times to produce one or more random numbers. You then use those random numbers in whatever way is appropriate for your particular scenario. In your case, one option would be to create a String containing all the letters and numbers you want to choose from and then use the value returned by the Random.Next method as an index into that String. You call Next five times to get five indexes to get five random Chars from the String and combine those five Chars into a new String.
 
Back
Top