It's handy.
If you have a method which accepts a string:
private void MyMethod(string s)
{
...
}
Then you can't afford to just use the string directly:
if (s.Trim() == "")
{
...
}
Because the attempt to call Trim on a
null
value will cause a "Null Reference" exception.
Coding it as:
if (string.IsNullOrEmpty(s))
{
...
}
Avoids that, and does the same check to ensure the string isn't just "" at the same time.
In .NET 4.0 and above, you also get:
if (string.IsNullOrWhitespace(s))
{
}
Which is even more helpful!