Compiler Warning (level 2) CS0652
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Warning (level 2) CS0652

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;
© 2016 Microsoft