が欠落している、そして今、私は、Visual StudioでWindowsフォームに取り組んでいます。「のSystem.InvalidOperationException」、カテゴリ名は、私は現在、C#で基本的なコーディングコースをやってる
私は私のプログラム(非常に基本的な電卓)を起動するために行くとき、私はこのエラーを取得:
すべてのこのようなものは、Visual Studioによって自動的に追加されているように見えるので、私はありませんよなぜそれがクラッシュしているのか確かめてください。
私は行を削除する場合は、プログラムが正常に実行され、正常に動作、それもありますなぜ私は混乱している、そしてなぜ自動的に追加何かが、このような例外を引き起こすだろう強調しました。プログラムの詳細については
は、こちらのフォームの完全なコードです:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinForm_Activity_27
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnCalculate_Click(object sender, EventArgs e)
{
int num1, num2 = 0;
string calcType = "";
if (!((Int32.TryParse(textNum1.Text, out num1)) && (Int32.TryParse(textNum2.Text, out num2))))
{
MessageBox.Show("Thats not right.");
return;
}
foreach (RadioButton rdo in grpMathOptions.Controls)
{
if (rdo.Checked == true)
{
calcType = rdo.Text;
}
}
switch(calcType)
{
case "Addition": textResult.Text = (num1 + num2).ToString();
break;
case "Subtraction": textResult.Text = (num1 - num2).ToString();
break;
case "Multiplication": textResult.Text = (num1 * num2).ToString();
break;
case "Division": textResult.Text = ((Double)num1/(Double)num2).ToString();
break;
}
}//end of btnCalculate_Click
}
}
このエラーが起こっている理由のすべてのアイデアと私は非常になり、将来のプロジェクトで再び起こってからそれを停止する方法感謝。
どのラインではuがこの例外を得るのですか? – Mainak