Compiler Warning (level 2) CS0458
The result of the expression is always 'null' of type 'type name'
This warning is caused by a nullable value type expression that always results in null
.
The following code generates warning CS0458.
This example illustrates a number of the different operations with nullable value types that will cause this error.
// CS0458.cs
using System;
public class Test
{
public static void Main()
{
int a = 5;
int? b = a + null; // CS0458
int? qa = 15;
b = qa + null; // CS0458
b -= null; // CS0458
int? qa2 = null;
b = qa2 + null; // CS0458
qa2 -= null; // CS0458
}
}
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: