Password masking console application

I tried the following code… string pass = “”; Console.Write(“Enter your password: “); ConsoleKeyInfo key; do { key = Console.ReadKey(true); // Backspace Should Not Work if (key.Key != ConsoleKey.Backspace) { pass += key.KeyChar; Console.Write(“*”); } else { Console.Write(“\b”); } } // Stops Receving Keys Once Enter is Pressed while (key.Key != ConsoleKey.Enter); Console.WriteLine(); Console.WriteLine(“The Password … Read more

Converting String Array to an Integer Array

You could read the entire input line from scanner, then split the line by , then you have a String[], parse each number into int[] with index one to one matching…(assuming valid input and no NumberFormatExceptions) like String line = scanner.nextLine(); String[] numberStrs = line.split(“,”); int[] numbers = new int[numberStrs.length]; for(int i = 0;i < … Read more