Compiler Warning (level 2) CS0472

The result of the expression is always 'value1' since a value of type 'value2' is never equal to 'null' of type 'value3'

The compiler should warn if you use an operator with a constant null value.

Example

The following sample generates CS0472.

public class Test  
{  
    public static int Main()  
    {  
        int i = 5;  
        int counter = 0;  
  
        // Comparison:  
        if (i == null)  // CS0472  
        // To resolve, use a valid value for i.  
            counter++;
        return counter;  
    }  
}