编译器警告(等级 2)CS0652
更新:2007 年 11 月
错误消息
与整数常数比较无意义;该常数不在“type”类型的范围之内
编译器检测到在常数和变量之间的比较中,常数超出了变量的范围。
下面的示例生成 CS0652:
// CS0652.cs
// compile with: /W:2
public class Class1
{
private static byte i = 0;
public static void Main()
{
short j = 256;
if (i == 256) // CS0652, 256 is out of range for byte
i = 0;
}
}