Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 4
    It isn't trivial if you check a string for string.Empty or "". One should really use String.IsNullOrEmpty as Eugene Katz pointed out. Otherwise you will get unexpected results. Commented Feb 27, 2014 at 13:36
  • @Sigur How do you use String.IsNullOrEmpty to set a variable to an empty string, or to pass an empty string as a function argument? Commented Oct 28, 2021 at 15:34
  • To set a string to empty use String.Empty. To check for an empty string use String.IsNullOrEmpty. Note that String.IsNullOrEmpty is a double check either of which belong to different domains. To Check for null is a technical check to avoid crashes, while checking for empty is a functional check. An empty string could be a valid value. So checking for it is usually done on different places in the code. Commented May 3, 2022 at 8:48