Author: sp00ks | Posted on: 10/7/2009 12:10:53 PM | Views : 269

Hello, I'm making a basic calculator for a webpage(very basic) and just wondering if there was a more code efficient way of going about this. (I can usually make things work, but hardly ever the most efficient way)

protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { lstOperations.Items.Add("x"); lstOperations.Items.Add("/"); lstOperations.Items.Add("+"); lstOperations.Items.Add("-"); } } protected void cmdCalculate_Click(object sender, EventArgs e) { double leftHand = Convert.ToInt32(txtLhsNumber.Text); double rightHand = Convert.ToInt32(txtRhsNumber.Text); string Operator = lstOperations.SelectedItem.ToString(); double results = 0.0; if(Operator == "x") { results = (leftHand * rightHand); ...

Go to the complete details ...