的String.Empty和“,”与空之间的区别是什么?区别、String、Empty

2023-09-04 00:26:01 作者:左语

可能重复:   What是的String.Empty和&ldquo之间的差异;”的

等同于的String.Empty

这是pferred初始化字符串值$ P $?

解决方案

 公共密封类字符串{
    // ...
    公共静态只读字符串空=;
    // ...
}
 

使用当你要重新present没有价值;

使用的String.Empty 当你要重新present,有一个值,但该值是一个空字符串。

string.Empty与 的区别

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.