可能重复:
What is the difference between String.Empty and “”为什么要使用name = System.String.Empty;而不是name =“”;
哪一个更好?
name = System.String.Empty;
OR
name = "";
可能重复:
What is the difference between String.Empty and “”为什么要使用name = System.String.Empty;而不是name =“”;
哪一个更好?
name = System.String.Empty;
OR
name = "";
我这样做是因为FxCop的,如果我不抱怨。更难以读懂?
我使用“”,因为它的眼睛比String.Empty
容易得多。迄今为止,它还没有给我带来任何问题,并且我一直在.Net中开发多年。
编辑:这只是直到.NET 1.1。根据What is the difference between String.Empty and "" (empty string)?不适用于更高版本。
如果您说""
您正在创建一个新的object
,其中String.Empty
is a read-only field已经初始化,它不会创建任何对象。
根据重复问题中的答案不成立 – Leany 2011-05-14 01:14:22