What is the difference between String.Empty and \"\" (empty string)?

Answer

In .Net pre 2.0, \"\" creates an object while String.Empty creates no object. So it is more efficient to use String.Empty.

Source of information

.Length == 0 is the fastest option, but .Empty makes for slightly cleaner code.

As @chadmyers mentioned, in version 2.0 and above of .Net, all occurrences of \"\" refer to the same string literal.

So \"\" is pretty equivalent to .Empty, but still not as fast as .Length == 0.

All string Questions

Ask your interview questions on string

Write Your comment or Questions if you want the answers on string from string Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---