Windows Phone 7 응용 프로그램에서 개체의 필드를 설정하는 데 문제가 있습니다 (소형 프레임 워크와 관련이 있으며 Windows에만 국한되지는 않습니다). 전화 7). 이 값은 struct
유형의 값 설정에만 해당됩니다.Windows Phone 7에서 개체에 구조체 형식의 필드를 설정하는 방법
// fieldName is the name of the field I'm interested in setting
FieldInfo fieldInfo = target.GetType().GetField(fieldName);
// target is the object I'm setting the value on
// value is the value that I am setting
fieldInfo.SetValueDirect(__makeref(target), value);
불행하게도 SetValueDirect
은 윈도우 폰 7에 존재하지 않는, 단순히 대상으로 아무것도하지 않는 SetValue
를 사용 : 일반적으로 나는 다음과 같은 사용합니다. 리플렉션을 통해 WP33에서 struct
필드를 설정하는 다른 방법이 있습니까?