title: Why my Bool value changes in catch block even if there was no error?
body: <p>I'm still learning c# and came across this problem , i wanted to make a program that make sure that the user enters an integer . but when i do this , i'm stuck in an infinite loop . Why the the bool b; variable change its value in catch block even if the user typed an integer ? 
  My code : </p>
  
  <pre><code>class MainClass
  {
      public static void Main (string[] args)
      {
          int n= 0;
          bool b = true;
          do {
              try {
                  Console.WriteLine ("Enter an integer : ");
                  n = Convert.ToInt32 (Console.ReadLine ());
              } catch (Exception e) {
                  Console.WriteLine (e.Message);
                  b = false;
              } finally {
                  Console.WriteLine (n);
              }
          } while(b == false);
      }
  }
  </code></pre>
  
  <p>but i fixed the problem when i did this : </p>
  
  <pre><code>class MainClass
  {
      public static void Main (string[] args)
      {
          int n= 0;
          bool b;
          do {
              try {
                  b = true;
                  Console.WriteLine ("Enter an integer : ");
                  n = Convert.ToInt32 (Console.ReadLine ());
              } catch (Exception e) {
                  Console.WriteLine (e.Message);
                  b = false;
              } finally {
                  Console.WriteLine (n);
              }
          } while(b == false);
      }
  }
  </code></pre>
  
  <p>can someone explain please ?</p>