To create a password with uppercase, lowercase letters, numbers and symbols in C#, you can use the following code:
main.cs600 chars22 lines
In this example, we define four different strings containing uppercase letters, lowercase letters, digits, and symbols respectively. We then concatenate these strings into a single string called allChars
.
Next, we create a Random
object and use the Enumerable.Repeat
method to create an array of 12 characters randomly chosen from allChars
. Finally, we use the string
constructor to create a new string from the array of characters, and print it to the console.
This will generate a random password with a length of 12 characters containing a mix of uppercase letters, lowercase letters, numbers, and symbols.
gistlibby LogSnag