In C#, I want to initialize a string value with an empty string.
How should I do this? What is the right way, and why?
string willi = string.Empty;
On http://blogs.msdn.com/b/brada/archive/2003/04/22/49997.aspx :
As David implies, there difference between
String.Empty
and""
are pretty small, but there is a difference.""
actually creates an object, it will likely be pulled out of the string intern pool, but still... whileString.Empty
creates no object... so if you are really looking for ultimately in memory efficiency, I suggestString.Empty
. However, you should keep in mind the difference is so trival you will like never see it in your code...
As forSystem.String.Empty
orstring.Empty
orString.Empty
... my care level is low ;-)