これは非常に単純な要件です。
テキストボックスに整数値が入力されていると仮定します。
private void button1_Click(object sender, EventArgs e)
{
// Declare variables for addition
int a, b;
// If convertion of textbox values to integer is successful
// If integer parsing is successful, the value entered in textbox1 will go to variable a
// and the value entered in textboxb will go to variable b
if (int.TryParse(textBox1.Text, out a) && int.TryParse(textBox2.Text, out b))
{
// Add a and b and assign display its value in label
label1.Text = (a + b).ToString();
}
}
これが役に立ちます。シーナからのコメントとして。また、C#のチュートリアルを終了するための基本的な終わりまでお勧めします。
ほとんどの場合、Windowsフォームのチュートリアルが必要です。それが良いスタートとして役立つことを願っています:https://www.youtube.com/watch?v=Is1EHXFhEe4 –
さて、私はそれをチェックします、ありがとう。 –