Essentially, I'm trying to check if textbox2.Text
contains anything that isn't an integer. This is an incredibly inefficient way of doing it, but it's the only way I could figure out. Is there anything better that I could do?
char[] ca = textBox2.Text.ToCharArray();
foreach (char c in ca)
{
string s = "1234567890";
char[] ca2 = s.ToCharArray();
if (c != ca2[0] && c != ca2[1] && c != ca2[2] && c != ca2[3] && c != ca2[4] &&
c != ca2[5] && c != ca2[6] && c != ca2[7] && c != ca2[8] && c != ca2[9])
{
MessageBox.Show("Non-integer detected in text box.");
EndInvoke(null);
}
}
int i = int.Parse(textBox2.Text);