Question: I'm using C# to make a Windows Form Application. My form has 4 labels, 4 text boxes, 2 buttons. I'm having trouble getting the area
I'm using C# to make a Windows Form Application. My form has 4 labels, 4 text boxes, 2 buttons. I'm having trouble getting the area and perimeter. When I enter length and width and push calculate button, nothing shows in textbox for area and perimeter. Can you please explain what I'm doing wrong. This is my event handler code for my calculate button:
private void btnCalculate_Click(object sender, EventArgs e) {
double length, width,area,perimeter;
length = Convert.ToDouble(txtLength.Text);
width = Convert.ToDouble(txtWidth.Text);
area = length * width;
perimeter = (2 * length + 2 * width);
String txtArea = Convert.ToString(area);
btnCalculate.Text = Convert.ToString(perimeter);
Console.WriteLine(txtArea);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
