6
Nullable 형식에서 Convert.ChangeType ()이 실패합니다.
문자열을 이름이 문자열 인 객체 속성 값으로 변환하고 싶습니다. 나는 이것을 이렇게하려고 노력하고있다 : string modelProperty = "Some Property Name"; string value = "SomeValue"; var property = entity.GetType().GetProperty(modelProperty); if (property != null) { property.SetValue(entity, Convert.ChangeType(value, property.PropertyType), null); } 문제는 속성 유형이 nullable 유형 인 경우 실패하고 잘못된 캐스트 예외가 발생한다는 …
301
c#
.net
reflection