title: How to take input from user in C#?
body: <p>I have the following program.</p>
  
  <pre><code>using System;    
  public class myeventhandler
  {
      private int x;
      private int y;
  
      public myeventhandler(int a, int b)
      {
          x = a;
          y = b;
      }
  
      public myeventhandler()
      { 
      }
  
      public int add()
      {
          return x + y; 
      }
  
      public int sub()
      {
          return x - y;
      }
  
  }
  
  public class test
  {
      public static void Main()
      {
          int a, b;
  
          Console.WriteLine("enter the first number");
          a = Convert.ToInt32(Console.ReadLine());
          Console.WriteLine("enetr the second no");
          b = Convert.ToInt32(Console.ReadLine());
          myeventhandler mh = new myeventhandler(a,b);
          int z = mh.add();
          Console.WriteLine("you enetered {0} and {1} whose sum is {}", a, b,z);
          Console.ReadKey();
          //Console.WriteLine("the sum of {0} and {1} is {2}", a, b, mh.add());
          //Console.ReadKey();         
      }
  }
  </code></pre>
  
  <p>When I run this program, it stops working after taking both the input. I cannot find what's wrong here.</p>
  
  <p>As shown in the code I believe the value taken from user is first converted to int and then saved to variable a.</p>
  
  <p>If it is so then what's the problem?</p>