进出口工作在decimal
到binary converter
完美的作品在控制台上,然后我得到我的核心数学运算,这些错误:的Visual C#错误:System.Windows.Forms.Button不包含定义ToInt32
System.Windows.Forms.Button
不包含ToInt32
的定义,并没有扩展方法ToInt32
接受System.Windows.Forms.Button
类型的第一个参数可以找到(是否缺少using指令或程序集引用?) 线:93
否过载对方法“的ToString '需要2个参数行:94
System.Windows.Forms.Button不包含“ToInt32”的定义,并且没有找到接受类型为“System.Windows.Forms.Button”的第一个参数的扩展方法“ToInt32”(您是否缺少使用指令或程序集参考)线: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();
}
}
}
您能告诉我们确切的情况吗?我的想法是,你已经调用了一个按钮控制“转换”,这将抛出此。更改按钮的名称可能会有所帮助。另外:避免使用“goto”..它有接近零的需求,并使代码难以遵循。 – 2012-08-13 03:47:51