的String.Empty和“,”与空之间的区别是什么? [英] What is the difference between String.Empty and “” and null?

查看:197
本文介绍了的String.Empty和“,”与空之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  <一href="http://stackoverflow.com/questions/151472/what-is-the-difference-between-string-empty-and">What是的String.Empty和&ldquo之间的差异;&rdquo;的

等同于的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.

这篇关于的String.Empty和“,”与空之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆