Edit

Share via


Compiler Error CS0037

Cannot convert null to 'type' because it is a non-nullable value type

The compiler cannot assign null to a value type; null can only be assigned to a reference type or to a nullable value type. struct is a value type.

The following sample generates CS0037:

// CS0037.cs  
public struct s  
{  
}  
  
class a  
{  
   public static void Main()  
   {  
      int i = null;   // CS0037  
      s ss = null;    // CS0037  
   }  
}