可能重复: What是的String.Empty和&ldquo之间的差异;”的
是,
等同于的String.Empty
?
这是pferred初始化字符串值$ P $?
解决方案 公共密封类字符串{
// ...
公共静态只读字符串空=;
// ...
}
使用空
当你要重新present没有价值;
使用的String.Empty
当你要重新present,有一个值,但该值是一个空字符串。
Possible Duplicate: What is the difference between String.Empty and “”
Is ""
equivalent to String.Empty
?
Which is preferred for initializing string values?
解决方案public sealed class String {
//...
public static readonly String Empty = "";
//...
}
Use null
when you want to represent that there is no value;
Use String.Empty
when you want to represent that there is a value, but the value is a blank string.