title: Implementing Try Catch for no input and invalid input
body: <p>I want to do this because I would like to block inputs that will crash my program. I tried doing it like this but I get the errors use of unassigned parameter total and the out parameter totalstring  and total must be assigned before control leaves current method.</p>
  
  <pre><code>private static void Start(out String totalString, out int total) 
      {
          Console.WriteLine("How Many ? (2-4)");
          Console.WriteLine("");
  
          try
          { totalString = Console.ReadLine();
              total = int.Parse(totalString);
  
  
          }
          catch
              {
                  Console.WriteLine("");
              }
          bool flag = false;
  
          if ((total &lt;= 1) || (total &gt; 4)) //loop to reject invaid input
              while (flag == false)
              {
  
                  if ((total &lt;= 1) || (total &gt; 4))
                  {
  
                      Console.WriteLine("Invalid input. How many?");
  
  
                      totalString = Console.ReadLine();
                      total = int.Parse(totalString);
  
                      Console.Clear();
  
                  }
  
                  else if ((total &gt;= 2) || (total &lt;= 4))
                  {
  
                      flag = true;
                  }
              }
  
   Console.Clear();
          Console.WriteLine("Player Numbers :" + total); 
          Console.WriteLine();
  
          players = new Player[total];
      }
  }
  }
  </code></pre>
  
  <p>Sorry about that :)</p>