Why use constant literal “” instead of string.Empty in C#

There is only subtle differences between “” and string.Empty, but indeed they are:

  1. string.Empty cannot be used in switch control statements;
  2. string.Empty cannot be used as default parameter in method;
  3. string.Empty cannot be used in attribute arguments;
  4. string.Empty cannot be used in all cases, it means lost naming consistency in project or solution;
  5. “” performance is much better in conditional statements, see resources below;
  6. always prefer compile time check instead of runtime check – “” literal is resolved on compile-time, when string.Empty literal is resolved on runtime to “”;
  7. “” takes less space, easier to write;
  8. “” is more commonly used between different programming languages.


C# string.Empty Example – Dot Net Perls

What is the difference between String.Empty and “” (empty string)?

Leave a Reply

Your email address will not be published. Required fields are marked *