我用枚举属性在我的的EntityFramework 的5类, 但在数据库中该字段为空。视觉工作室给这个属性必须是一个可为空性的错误。我的问题是:是枚举引用类型或值类型
I used Enum property in my EntityFramework 5 class, but in the database this field is nullable. Visual studio gives the error that this property must be a nullable property. My question is: is Enum a reference type or a value type?
推荐答案
System.Enum
是引用类型,但是任何的的具体的枚举类型是值类型。以同样的方式, System.ValueType
是引用类型,但所有类型从它继承(超过 System.Enum )是值类型。
System.Enum
is a reference type, but any specific enum type is a value type. In the same way, System.ValueType
is a reference type, but all types inheriting from it (other than System.Enum
) are value types.
所以,如果你有一个枚举富
和你想有一个可为空的属性,你需要的属性类型为富?
。
So if you have an enum Foo
and you want a nullable property, you need the property type to be Foo?
.
相关推荐
最新文章