为什么字符串可以为空?

时间:2013-01-17 01:20:06

标签: c# .net

  

可能重复:
  The type ‘string’ must be a non-nullable type in order to use it as parameter T in the generic type or method ‘System.Nullable<T>’

正如标题所说,为什么字符串默认在C#中可以为空,但如果我想要,比如说,int或double是null,我必须明确说出来?

1 个答案:

答案 0 :(得分:11)

因为string是引用类型,所以从object和[大多数]其他默认类型派生的是值类型,从System.ValueType隐式派生;