Compiler Warning (level 2) CS0652
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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