我正在研究一个decimal
在binary converter
控制台上完美运行的方法,然后我得到了关于我的核心数学运算的这些错误:
System.Windows.Forms.Button
不包含定义,也找不到接受第一个类型参数的ToInt32
扩展方法(您是否缺少 using 指令或程序集引用?) Line:93ToInt32
System.Windows.Forms.Button
方法“ToString”没有重载需要 2 个参数 Line:94
System.Windows.Forms.Button 不包含“ToInt32”的定义,并且找不到接受“System.Windows.Forms.Button”类型的第一个参数的扩展方法“ToInt32”(您是否缺少 using 指令或装配参考?)行:103
这是代码:
public void Convert_Click(object sender, EventArgs e)
{
string Input;
bool IsNotBinary;
string Answer;
Start:
Input = UserInput.Text;
int InputLength = Input.Length;
if (InputLength > 10)
{
UserInput.Text = "Overflow";
goto Start;
}
int Int;
bool IsANumber = int.TryParse(Input, out Int);
if (IsANumber == false)
{
UserInput.Text = "Invalid Character";
goto Start;
}
IsNotBinary = Input.Contains("3");
if (IsNotBinary == true)
{
goto End;
}
IsNotBinary = Input.Contains("4");
if (IsNotBinary == true)
{
goto End;
}
IsNotBinary = Input.Contains("5");
if (IsNotBinary == true)
{
goto End;
}
IsNotBinary = Input.Contains("6");
if (IsNotBinary == true)
{
goto End;
}
IsNotBinary = Input.Contains("7");
if (IsNotBinary == true)
{
goto End;
}
IsNotBinary = Input.Contains("8");
if (IsNotBinary == true)
{
goto End;
}
IsNotBinary = Input.Contains("9");
End:
if (IsNotBinary == true)
{
// decimal to binary
int InputInt = Convert.ToInt32(Input); // converts the string "Input" to the int "InputInt"
Answer = Convert.ToString(InputInt, 2);
UserInput.Text = Answer;
}
else
{
// binary to decimal
Answer = Convert.ToInt32(Input, 2).ToString();
UserInput.Text = Answer;
}
Console.ReadLine();
goto Start;
}
public void QuitButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}