using System; using System.Timers; namespace ConsoleApp2 { class Program { static void Main(string[] args) { //defining variables and references Random rnd = new Random(); const string pool = " 0123456789!$%&~#"; int width, height, timeinput; decimal time = 0; bool breakoff = false; Console.ForegroundColor = ConsoleColor.DarkGreen; //userinput Console.WriteLine("Enter Width: (in characters)"); width = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Height: (in characters)"); height = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Runtime in min:"); timeinput = Convert.ToInt32(Console.ReadLine()); Console.Clear(); //setting up array for matrix string[,] Zeile = new string[height, width]; int[] Indexspeicher = new int[width]; do //endless loop (timer, forcequit) { if (time%5 == 0) { for (int indexgen = 0; indexgen < width; indexgen++) { Indexspeicher[indexgen] = rnd.Next(2); } } //fill matrix with random chars for (int row = 0; row < height; row++) { for (int chargen = 0; chargen < width; chargen++) { if(Indexspeicher[chargen] == 1) { var c = pool[rnd.Next(0, pool.Length)]; Zeile[row, chargen] = Convert.ToString(c); } } } //write matrix to string, less vsync int rowLength = Zeile.GetLength(0); int colLength = Zeile.GetLength(1); string output = ""; for (int i = 0; i < rowLength; i++) { if (i > 0) { output += "\n"; } for (int j = 0; j < colLength; j++) { output += string.Format("{0} ", Zeile[i, j]); } } //format and output Console.WriteLine(output); Console.Write(Environment.NewLine + Environment.NewLine); //forcequit if (Console.KeyAvailable) if (Console.ReadKey().KeyChar == 'Q') break; //timer System.Threading.Thread.Sleep(1000); Console.Clear(); time += 1; if (time >= (timeinput * 60)) { breakoff = true; } } while (breakoff == false); } } }