Phil Phil - 4 months ago 34
C# Question

Easier way of writing null or empty?

I'm sure I've missed something here. With a certain project I need to check if a string is empty or null.

Is there an easier way of writing this?

if(myString == "" || myString == null)


Yes, there's a helper method for exactly this already:

if (string.IsNullOrEmpty(myString)) {