Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0037 

Error Message

Cannot convert null to 'type' because it is a value type

The compiler cannot assign null to a value type; null can only be assigned to a reference type or to a Nullable type. struct is a value type. For more information, see Nullable Types (C# Programming Guide).

The following sample generates CS0037:

// CS0037.cs
public struct s

class a
   public static void Main()
      int i = null;   // CS0037
      s ss = null;    // CS0037

Community Additions

© 2015 Microsoft