PropertyInfo GetValue() Object does not match target type

前端 未结 4 1495
被撕碎了的回忆
被撕碎了的回忆 2021-01-17 15:33

I want to read value of a T type

  public virtual ActionResult Edit(TEditDTO editedDTO)
    {
        if (!ModelState.IsValid) return View(editedDTO);
               


        
4条回答
  •  遇见更好的自我
    2021-01-17 16:01

    You should pass the instance of TEditDTO to GetValue method not the type instance.

    var Id = prop.GetValue(editedDTO);
    

提交回复
热议问题