title: While loop not working while using bool in C#
body: <p>My while loop is not working. There are 3 choices on the menu, and the users keep entering inputs until they press "esc". But the program exits after the user enters one of the choices, and it doesn't return to the menu. How can I fix my while loop? Please help.</p>
  
  <pre><code>bool runApp = false;//menu.cs #12 Need to false sinces the loop is true
          Student[] students = new Student[35];
          //Application loop
          while (runApp);
          {
              Console.Clear();
              Console.WriteLine("\n\tGrade Book Menu\n");
              Console.WriteLine("\t1) Add Student");
              Console.WriteLine("\t2) Enter Student Grades");
              Console.WriteLine("\t3) List Student Grades");
              Console.Write("\nEnter Selection or Press Escape to exit: ");
              ConsoleKeyInfo key = Console.ReadKey();
              if (key.Key == ConsoleKey.Escape)
              {
                  runApp = false;
              }
              else
              {
                  switch (key.Key)
                  {
                      case ConsoleKey.NumPad1:
                      case ConsoleKey.D1:
                          //Get the current student count stored in the Student Class variable
                          int indexForNewStudent = Student.GetStudentCount();
                          indexForNewStudent = 0;
                          Console.Write("\nEnter Student Name: ");
                          //Instantiate a Student object and place it in the array of Student objects called student
                          students[indexForNewStudent] = new Student(Console.ReadLine()); //Call overloaded constructor
                          //Increment Student count
                          Student.SetStudentCount(indexForNewStudent + 2); //Add to index to account for new student
                          break;
                      case ConsoleKey.NumPad2:
                      case ConsoleKey.D2:
                          Console.WriteLine("\nEnter the Student Number.  Use List Students to get Student Number.");
                          int studentNumber = 0; //Temporary variable to hold the student number to enter grades
                          //Test the entered string is a number and between 1 and 30
                          if ((int.TryParse(Console.ReadLine(), out studentNumber)) &amp;&amp; (studentNumber &lt;= 1) &amp;&amp;
                               (studentNumber &gt;= 30))
                          {
                              //In the event a student has not been added this code will crash
                              if (Student.GetStudentCount() &lt; 0) //Has a student been added?
                                  students[studentNumber - 1].EnterStudentScores(); //Subtract 1 from enterd number for array index
                              else
                                  Console.WriteLine("A student has not been added");
                          }
                          else
                          {
                              Console.WriteLine("Invalid Student Number.  Enter a number from 1 to 30");
                          }
                          break;
                      case ConsoleKey.NumPad3:
                      case ConsoleKey.D3:
                          Student.ListStudents(students);
                          break;
                      default:
                          Console.WriteLine("Invalid Menu Selection");
                          break;
                  }
                  Console.Write("Press a key to return to Menu");
                  Console.ReadKey();
              }
          }
          Console.Write("\nExiting Application.  Press any key to close window... ");
          Console.ReadKey();
  </code></pre>