編譯器警告 (層級 2) CS0458
更新:2007 年 11 月
錯誤訊息
這個運算式的結果一定是 'type name' 型別的 'null'
這個警告是因為 nullable 運算式總是得到 null 而產生的。
下列程式碼會產生警告 CS0458:
範例
這個範例說明會導致這個錯誤的各種作業 (這些作業都擁有 nullable 型別)。
// 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
}
}