Possible Duplicate:
What is the difference between String.Empty and “”
Hello
Simple Question;
Why
Textbox1.Text = String.Empty;
is better than
Textbox1.Text = "";
?
Possible Duplicate:
What is the difference between String.Empty and “”
Hello
Simple Question;
Why
Textbox1.Text = String.Empty;
is better than
Textbox1.Text = "";
?
It's not, really.
Basically, decide which you find to be more readable. Personally I use "" instead of string.Empty, but others prefer the latter.
Back in .NET 1.x days apparently there was some tiny performance difference (almost certainly irrelevant in real apps) but I believe these days even that's gone.
Use whichever you and your find most readable.
Because String.Empty is actually defined as ""
Best practices dictate not to use string literals but constants.
On a funnier note: String.Empty is/looks more Object Oriented-ISH.
int.Zero instead of 0, for example?int.Zero. I'm going to have to use that just because I can now, but not really. Unless the value of zero might change in the future.... or in another culture?..... Sounds like good fodder for a Dilbert comic.string.Empty as you can't change that... if you have multiple places where you want to use the same logical value in a flexible way, by all means create a constant field for that... but using string.Empty provides no "best practice" benefit here."" as either an actual empty string literal, or unfinished work because the previous dev never wrote it out and never left a note to finish it. The rather frequent time sink of having to double check this is small but a pain at times. string.Empty provides much much more clarity in those types of situations. In either scenario, prioritize what produces the clearest code and docs. If you are doing that already, then its tomato tomato
string.Emptyis better than"".