Heya;
Im a newbie in C# and Im trying to loop 5 times in a console app. However the program exits on the second entry. The problem seems to be the For control . Anyone can point out to me the mistake pls/
Code:namespace ConsoleSwitch { class Program { static void Main(string[] args) { int x; string colour,str; string Blue,Red, Yellow ; Console.WriteLine("Enter the primary colours colour"); colour = Console.ReadLine(); for (x = 1; x <= 5; x++) ; switch (colour) { case "Blue": Console.WriteLine("Blue is a primary colour"); //str = Console.ReadLine(); break; case "Red": Console.WriteLine("Red is a primary colour"); //str = Console.ReadLine(); break; case "Yellow": Console.WriteLine("Yellow is a primary colour"); break; case "White": Console.WriteLine("White is a primary colour"); break; case "Black": Console.WriteLine("Black is a primary colour"); break; default: Console.WriteLine("Colour is NOT a primary colour"); //str = Console.ReadLine(); break; } //end of switch str = Console.ReadLine(); } //end of For }





Reply With Quote