using System; public class Test { public static void Main() { int asciiValue = 0; char asciiChar = ' '; char[] passwordArray = new char[1000]; Random ranAsciiGroup = new Random(); Random ascValue = new Random(); int[] digithist = new int[10]; int[] lchist = new int[26]; for (int i = 0; i < passwordArray.Length; i++) { int randomAsc = 0; randomAsc = ranAsciiGroup.Next(1, 4); //Console.WriteLine(randomAsc); if (randomAsc == 1) { asciiValue = ascValue.Next(65, 91); lchist[asciiValue - 65]++; //Console.WriteLine(asciiValue); } else if (randomAsc == 2) { asciiValue = ascValue.Next(97, 123); //Console.WriteLine(asciiValue); } else if (randomAsc == 3) { asciiValue = ascValue.Next(48, 58); digithist[asciiValue - 48]++; //Console.WriteLine(asciiValue); } asciiChar = (char)asciiValue; passwordArray[i] = asciiChar; //validPassword = true; } Console.WriteLine("lower case count: " + string.Join(", ", lchist)); Console.WriteLine("digit count: " + string.Join(", ", digithist)); } }
Standard input is empty
lower case count: 31, 38, 41, 38, 35, 31, 43, 45, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 digit count: 0, 0, 0, 0, 0, 0, 28, 83, 111, 101