Jam*_*ill 7 c# string initialization
我试图理解为什么不可为空的字符串初始化为null而不是空字符串.例如:
//Property of class foo
public string Address_Notes { get; set; }
//Create instance of foo
foo myFoo = new foo();
//Get value of Address_Notes
var notesValue = myFoo.Address_Notes; //Returns null
Run Code Online (Sandbox Code Playgroud)
我是否认为不可空字符串的值应默认为String.Empty?除了自定义getter之外,是否存在强制此行为的标准方法?
| 归档时间: |
|
| 查看次数: |
4971 次 |
| 最近记录: |