Im working on a decimal
to binary converter
that works perfectly on a console and then i get these errors about my core math operations:
System.Windows.Forms.Button
does not contain a definition for ToInt32
and no extension method ToInt32
accepting a first argument of type System.Windows.Forms.Button
could be found (are you missing a using directive or an assembly reference?)
Line:93
No overload for method 'ToString' takes 2 arguments Line:94
System.Windows.Forms.Button does not contain a definition for 'ToInt32' and no extension method 'ToInt32' accepting a first argument of type 'System.Windows.Forms.Button' could be found (are you missing a using directive or an assembly reference?) Line:103
Here is the code:
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();
}
}
}