Phil Phil - 1 year ago 81
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)

Answer Source

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

if (string.IsNullOrEmpty(myString)) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download