Edit

Share via


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.

Example

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  
    }  
}