int.Parse throws a FormatException when given a zero length string so that check is definitely necessary (at least it is for my application)
I
indranilbanerjee
@indranilbanerjee
Posts
-
TextBox for number -
TextBox for numberAlmost... private void textBox_TextChanged(object sender, System.EventArgs e) { try { if(this.Text.Length > 0) int.Parse(this.Text); this.validValue = this.Text } catch (System.FormatException) { this.Text = this.validValue; } }