Compiler Warning (level 2) CS0464
Comparing with null of type 'type' always produces 'false'
This warning is produced when you perform a comparison between a nullable value type variable and null, and the comparison is not ==
or !=
. To resolve this error, verify if you really want to check a value for null
. A comparison like i == null
can be either true of false. A comparison like i > null
is always false.
The following sample generates CS0464.
C#
// CS0464.cs
class MyClass
{
public static void Main()
{
int? i = 0;
if (i < null) ; // CS0464
i++;
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: