閱讀英文

共用方式為


編譯器警告 (層級 2) CS0458

運算式的結果一律會是類型 'type name' 的 'null'

這個警告是由一律會導致 null 之可為 Null 的實值型別運算式所造成。

下列程式碼會產生警告 CS0458。

範例

這個範例說明可為 Null 實值型別將導致這個錯誤的數個不同作業。

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