How can I make my string property nullable?

前端 未结 9 1007
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 00:08

I want to make the Middle Name of person optional. I have been using C#.net code first approach. For integer data type its easy just by using ? operator to make

9条回答
  •  抹茶落季
    2020-12-14 00:15

    It's not possible to make reference types Nullable. Only value types can be used in a Nullable structure. Appending a question mark to a value type name makes it nullable. These two lines are the same:

    int? a = null;
    Nullable a = null;
    

提交回复
热议问题