Nullable object must have a value?

后端 未结 8 2369
旧时难觅i
旧时难觅i 2020-12-09 14:54

On the line: bool travel = fill.travel.Value; I am getting the following error:

Nullable object must have a value

a

8条回答
  •  伪装坚强ぢ
    2020-12-09 15:11

    You are trying to access property from the nonexistent object (your fill.travel is null, and you calling prop from it), you can use coalesce operator (.Net 4.0):

    bool travel = fill.travel ?? false;
    

提交回复
热议问题