Alex Rivera | Logout

String.Empty versus ""

Asked 2010-05-25T14:05:20.450
156

Possible Duplicate:
What is the difference between String.Empty and “”

How is String.Empty different from ""?

c#
Edit
Report

1 Answer

3

string.Empty is always the same object

"" is always a new object, which may have to be removed by the garbage collector.

Therefore you should always use string.empty instead of "".

string a="";
string b=string.Empty;

is translate to

IL_0000:  ldstr       ""
IL_0005:  ldsfld      System.String.Empty
answered 2010-05-25T14:08:28.580

Your Answer