In C# programming, Create a Windows application that contains two textboxes and
ID: 3559331 • Letter: I
Question
In C# programming,
Create a Windows application that contains two textboxes and two buttons. The textboxes should be used to allow the user to input two numeric values. The buttons should be labeled Add and Multiply. Create event-handler methods that retrieve the values, perform the calculations, and display the result of the calculations on a label. The label should initially be set to be invisible. Additional labels will be needed for the textboxes captions.
A sample run may look like this:
1. Before user enters values
Explanation / Answer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Add_two_numbers
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Add_button_Click(object sender, EventArgs e)
{
try
{
double a = Convert.ToDouble(textBox1.Text);
double b = Convert.ToDouble(textBox2.Text);
textBox3.Text = (a + b).ToString();
}
catch(Exception)
{
MessageBox.Show("invalid input");
}
}
}
}