Substitution for "case" function.

Oct 11, 2010 at 9:51 PM

Does anyone know a substitution for the case function, because I keep getting an error when I use too many case's.

here is my code I'm using: (it wont let me go over 5 case's please help????)

string command = Console.ReadLine();

            switch (command)
            {
                case "cmd":
                    {
                        Console.BackgroundColor = ConsoleColor.Gray;
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine("Commands:");
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.ForegroundColor = ConsoleColor.White;
                        //Console.WriteLine("[test]--a test program.");
                        Console.WriteLine("[time]--Displsys system time.");
                        Console.WriteLine("[reboot]--To reastart the system..");
                        Console.WriteLine("[cls]--Clear the screen.");
                        //Console.WriteLine("[welcome]--Dsiplays welcome screen.");
                        Console.WriteLine("[version]--Displays current version.");
                        goto Prompt;
                        // break;
                    }

                case "cls":
                    {



                        Console.Clear();

                        goto Prompt;

                    }
               
               
              
              

                case "time":
                    {



                        Console.WriteLine(time);
                       
                        goto Prompt;

                    }



                case "version":
                    {

                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("Centauri_v.1.0-preAlfa");
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.WriteLine("Copyright(C)Centauri 2010");
                        Console.WriteLine("This software is under the GNU General Public License.");
                        goto Prompt;

                    }






                case "reboot":
                    {
                        Console.Beep(1980, 990);
                        Console.Beep(1300, 800);
                        Console.Beep(1100, 750);
                        Console.Beep(1000, 1000);
                        Cosmos.Sys.Deboot.Reboot();
                        break;
                    }





                default:
                    {

                        Console.WriteLine("No such command");

                        command = null;

                        goto Prompt;
                    }

Coordinator
Oct 12, 2010 at 12:01 AM
On 10/11/2010 4:51 PM, anti149 wrote:
> Does anyone know a substitution for the case function, because I keep
> getting an error when I use too many case's.

if then else
Oct 20, 2010 at 2:34 AM
Edited Oct 21, 2010 at 12:24 AM

I have been getting the same problem. I think I am just going to use the if and else like kudzu said.