Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Visual Studio 2010のC#でのプログラミングは初めてです。保存ボタンをクリックすると、テキストボックスをnullまたは空にすることはできません。これを解決する方法を教えていただければ幸いです。
テキスト ボックス (.Textプロパティ) の値をテストして、入力されているかどうかを確認する必要があります。
.Text
string.IsNullOrWhitespaceステートメントで(.NET 4.0 以降) またはstring.IsNullOrEmptyメソッドを使用するifことは、良い出発点です。
string.IsNullOrWhitespace
string.IsNullOrEmpty
if
if(!string.IsNullOrWhitespace(aTextBox.Text)) { // it is not empty or null! }