How to check whether string has a
null values or it has not been assigned any values?

 Posted by vishalneeraj-24503 on 12/22/2013 | Category: C# Interview questions | Views: 755 | Points: 40
Answer:

We can check,whether string has null value or it does not contain any values with the help of IsNullOrEmpty static method of String Class.

IsNullOrEmpty returns true if string has null value or does not contain any values.

For Example:-

string str;

if(string.IsNullOrEmpty(str))
{
//string is null or empty
}
else
{
//string is not null or it some some values
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response