【发布时间】:2012-10-06 11:58:31
【问题描述】:
为什么在实际使用它进行比较之前,我总是需要为字符串变量赋值。 例如: 一些输入 - obj
string temp;
if (obj== null)
{
temp = "OK";
}
string final = temp;
我收到编译时错误 - 类似于 - 无法使用未分配的变量“temp”。但是字符串变量的默认值为'null',我想使用它。那么为什么不允许这样做呢?
【问题讨论】: