Search code examples
c#stringisnullorempty

How can I check whether a string variable is empty or null in C#?


How can I check whether a C# variable is an empty string "" or null?

I am looking for the simplest way to do this check. I have a variable that can be equal to "" or null. Is there a single function that can check if it's not "" or null?


Solution

  • if (string.IsNullOrEmpty(myString)) {
       //
    }