Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
the meaning of this code
C#
private void result_Click(object sender, EventArgs e)
       {
           double firstnumber = Convert.ToDouble(txtFirst.Text);
           double secondnumber = Convert.ToDouble(txtSecond.Text);

           if (rdbAddition.Checked == false && rdbSubtraction.Checked == false && rdbMultiplication.Checked == false && rdbDivision.Checked == false)
               MessageBox.Show("Please Select Operation Before Calculator", "Message Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);

           if (rdbAddition.Checked)
           {
               txtAnswer.Text = Convert.ToString(firstnumber + secondnumber);
           }
           else if (rdbSubtraction.Checked)
           {
               txtAnswer.Text = Convert.ToString(firstnumber - secondnumber);
           }
           else if (rdbMultiplication.Checked)
           {
               txtAnswer.Text = Convert.ToString(firstnumber * secondnumber);
           }
           else if (rdbDivision.Checked)
           {
               txtAnswer.Text = Convert.ToString(firstnumber / secondnumber);
           }
Posted

It means you have to pick up a beginners book on C# and work through it.

All this does is take two numbers that are entered in textboxes, check a few checkboxes to figure out what to do with them and perform the requested operation on those two numbers, storing the result in another textbox.

Really, this is bad code for a simple calculator.
 
Share this answer
 
This looks like a simple calculator app in WinForms.

It seems to take two numbers - firstnumber and secondnumber (stored as text in two TextBox controls); apply the appropriate arithmetic operation on them (determined by the state of a bunch of RadioButton controls) and store the result in a third TextBox.

That's pretty much it.
 
Share this answer
 
The meaning of this bunch of code is like this.

There are 2 TextBox accepting numbers, and 4 checkbox/radio button for addition, subtraction, multiplication and division.

First you enter some numbers then, this code checks if any of the check box is clicked or not, if no, then show a message "Please Select Operation Before Calculator", and if yes then it does the functionality of addition, subtraction, multiplication, or division accordingly.

Hope you understand this code block now.

Thanks
Tapan kumar
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900