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
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: