更新:2007 年 11 月
错误消息
可能非有意的引用比较;若要获取值比较,请将右边的值强制转换为类型“type”
编译器正在进行引用比较。如果要比较字符串的值,请将表达式的右边转换为 type。
下面的示例生成 CS0253:
// CS0253.cs
// compile with: /W:2
using System;
class MyClass
{
public static void Main()
{
string s = "11";
object o = s + s;
bool c = s == o; // CS0253
// try the following line instead
// bool c = s == (string)o;
}
}