Wednesday, April 22, 2015

reusing Ifs anywere without typing it over and over

Notwithstanding my question about "automatically initiate", the code in your last post could be rewritten like so...

while(true)
{
   string PlayerReply = Console.ReadLine()

   if(List.About.Contains(PlayerReply.ToLower()))
   {
       MessageBox.Show("Test");
   }
   else if (List.Quit.Contains(PlayerReply.ToLower()))
   {
       Environment.Exit(0);
   }
   else
   {
      break;
   }
}

No comments:

Post a Comment