cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)

前端 未结 9 695
陌清茗
陌清茗 2020-12-05 06:14

Error : cannot implicitly convert type \'bool?\' to \'bool\'. An explicit conversion exists (are you missing a cast?)

Code :



        
9条回答
  •  温柔的废话
    2020-12-05 06:48

    cast your nullable value to value type

    [HttpPost]
    public ActionResult Index(bool? checkOffAge)
    {
        if (checkOffAge != null) {
           model.CheckOffAge =(bool)checkOffAge;
        }
    }
    

提交回复
热议问题