string degerim = textBox1.Text; int Num; bool isNum = int.TryParse(degerim.ToString(), out Num); if (isNum) { } else { textBox1.Text = ""; }