Basic Calculator Program in using C#


  1. protected void ButtonNumberEqual_Click(object sender, EventArgs e)     
  2. {    
  3.     try     
  4.     {    
  5.         string Input = DisplayTextBox1.Text;    
  6.         DataTable table = new DataTable();    
  7.         Object answer;    
  8.         answer = table.Compute(Input, null);    
  9.         Answer.Text = answer.ToString();    
  10.         DisplayTextBox1.Text = DisplayTextBox1.Text + " = " + answer.ToString();    
  11.     } catch     
  12.     {    
  13.         Answer.Text = "ERROR :(";    
  14.     }    
  15. }