Possible Duplicate:
In C#, should I use string.Empty or String.Empty or “” ?
I just don't understand the benefits of using String.Empty over "". Aside it being strongly typed its longer.
So please, why should I be u开发者_运维问答sing this?
As has been mentioned string.Empty
creates no object where as ""
will create an object (albeit pulled out of the pool). The performance difference is minimal but the question should be what is more readable. I take the stance that string.Empty
sticks out more than ""
and I can clearly see the intent of the declaration (string.Empty vs null). Regardless of your choice you should be consistent throughout your code base.
String.Empty vs ""
There is no meaningful difference. See these (and other) questions elsewhere on SO:
In C#, should I use string.Empty or String.Empty or "" to intitialize a string?
Why is string.Empty more efficient than "" in .Net
String.Empty versus ""
What is the difference between String.Empty and “” and null?
Which should I use for empty string and why?
Difference between string.Empty and ""
精彩评论