S
Skeletron
Guest
Well, since C# did not have a IsNumeric function I had to make one for my project in C#.
Basically, IsNumeric will turn a string into a integer. If it catches a error whe converting then it ill return a false value 'else' it will return a true value.
There are many other methods that I can do to make this work like Convert.Int32 but anyway, this works fine.
I did not want to include Visual Basic namespace because it the processing power to incorporate VB.net into C# while compiling is quiet large.
Usage:
Basically, IsNumeric will turn a string into a integer. If it catches a error whe converting then it ill return a false value 'else' it will return a true value.
public static bool IsNumeric(string ValidString)
{
try
{
Int32.Parse(ValidString);
}
catch
{
return false;
}
return true;
}
There are many other methods that I can do to make this work like Convert.Int32 but anyway, this works fine.
I did not want to include Visual Basic namespace because it the processing power to incorporate VB.net into C# while compiling is quiet large.
Usage:
if ((!(IsNumeric(Convert.ToString(textBox4.Text))) == true))
{
MessageBox.Show("The textbox that is labeled 'Tries' has a null value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
#endregion

