What is the difference between the following coding ways:
if (String::IsNullOrEmpty(TextBox1->Text))
and
if (TextBox1->Text == "")
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first one checks for
nullas well.A TextBox->Text property will never be null but consider (C#):
The
IsNullOrEmpty()function is just a handy helper to check 2 (error) conditions at once.So your title is slightly off, this is about empty and null. Because:
A string is an object.
s1ands2are not strings but references (pointers) to strings.nullis a special reference value meaning ‘not pointing to an object’. An empty string is a valid string object with length=0