I put a button for the password generator program called generate. When this button is clicked, it puts the created password in the textbox, but when it creates the password by chance, sometimes it does not put the number in the password. I want to say that there must be a few numbers in each password by chance
This is the generate button code
private void Generate_Click(object sender, RoutedEventArgs e)
{
{
TextBox.SelectAll();
}
TextBox.Selection.Text = "";
int len_1 = Convert.ToInt32(Label.Text);
const string ssPass_1 = "__abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const string ValidChar_1 = ssPass_1;
StringBuilder result_1 = new StringBuilder();
Random rand_1 = new Random();
while (0 < len_1--)
{
result_1.Append(ValidChar_1[rand_1.Next(ValidChar_1.Length)]);
}
TextBox.Selection.Text = "mstsc\nnet user " + ssPass + " " + result_1.ToString() + "\nnet user " + ssPass + " " + result_1.ToString() + " /add\nnet localgroup Administrators " + ssPass + " /add\nnet localgroup \"Remote Desktop Users\"" + " /add " + ssPass + "\n";
}