ユーザーが数字を入力しない場合、またはテキスト ボックスが空白の場合にポップアップするエラー メッセージをフォームに表示したいと考えています。私が試してみました:
//If nothing is inserted in text, error box.
int value = 0;
if (string.IsNullOrWhitespace(txtBegin.Text) || !int.TryParse(txtBegin.Text, out value)) // Test for null or empty string or string is not a number
MessageBox.Show("Please enter a number!");
else
MessageBox.Show(string.Format("You entered: {0}!", value));
それは私にエラーを与えています:'string' does not contain a definition for 'IsNullOrWhitespace'