This documentation is archived and is not being maintained.

Compiler Warning (level 2) CS0652 

Error Message

Comparison to integral constant is useless; the constant is outside the range of type 'type'

The compiler detected a comparison between a constant and a variable where the constant is out of the range of the variable.

The following sample generates 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;
   }
}
Show: