C# .NET – string.IsNullOrEmpty() vs string.NotNullOrEmpty()

.netc++string

I'm curious if any developers use string.IsNullOrEmpty() more often with a negative than with a positive

e.g.

if (!string.IsNullOrEmpty())

This is how I use the method 99% of the time. What was the design decision for this?

Best Answer

Because "IsNullOrEmpty" is easier to understand than "NotNullOrEmpty". The latter could be interpreted as:

  1. It's not null and it's not empty
  2. It's not null or it is empty
Related Question