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