title: Escaping a function to get back to Main()
body: <p>I'm making a program that has little programs inside of it, and I've come to a dilemma. On my first mini-program which rearranges digits to find the greatest possible number from those digits, it asks if the user wants to quit. If they respond "Yes" then the function returns 0 which is evaluated in the main(string[] args) method. My problem is that whenever the user says "No", the mini-program still doesn't continue. Here's my source:</p>
  
  <pre><code>    namespace ACSL_Competition
      {
          class Program
          {
      static int DigitRearranger()
      {
          string[] mainString = {};
          Console.WriteLine("---------Welcome to the Digit Re-arranger!---------");
          Console.WriteLine("I take a positive number up to 10000, and find the highest number that can be made out of its digits.");
          Console.WriteLine("Instructions: Enter a number up to 10000, and see the results!");
          drLabel:
          Console.Write("Your Number: ");
  
          string input = Console.ReadLine();
          int inputNumber = 0;
          try { inputNumber = int.Parse(input); }
          catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); goto drLabel; }
  
          /*Placeholder code for the moment*/Console.WriteLine(inputNumber.ToString());
          evaluate:
          Console.Write("Do you want to exit? Yes/No: ");
          if (Console.ReadLine().Equals("Yes"))
              return 1;
          else if (Console.ReadLine().Equals("No"))
          {
              goto drLabel;
  
          }
          else
          {
              return 1;
          }
  
      }
      static void Main(string[] args)
      {
          Console.WriteLine("Welcome to the ACSL Competition Program. Choose a program to begin:");
          Console.Write("\n\t");
          Console.WriteLine("1\tDigit Re-arranger");
          label:
          Console.Write("\nProgram: ");
          string input = Console.ReadLine();
          int number = 0;
          try { number = int.Parse(input); }
          catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); goto label; }
          if (number == 1)
          {
              Console.WriteLine("\n");
              if (DigitRearranger() == 1)
              {
                  goto label;
              }
              else if (DigitRearranger() != 1)
              {
                  DigitRearranger();
              }
          }
          else if (!number.Equals(1))
          {
              Console.WriteLine("Not a valid program.");
              goto label;
          }
          //----------------
          Console.ReadLine();
      }
  }
  </code></pre>
  
  <p>}</p>