0
리플렉션 사용시 문제가있는 코드를 게시하고 있습니다. 필요에 따라 메시지 상자를 사용합니다. reflection을 사용하는 것처럼 property.i를 사용하지 않고 어떻게 Name Value를 얻을 수 있습니까? [재산으로 얻을 수 있습니다.] 저는 여기에 "비 정적 메서드는 대상이 필요합니다."오류를 얻고 날이 사전에 code.thanks 해결하기 위해 도와주세요리플렉션을 사용하여 중첩 된 클래스에서 값 가져 오기
public class CustomProperty<T>
{
private T _value;
public CustomProperty(T val)
{
_value = val;
}
public T Value
{
get { return this._value; }
set { this._value = value; }
}
}
public class CustomPropertyAccess
{
public CustomProperty<string> Name = new CustomProperty<string>("cfgf");
public CustomProperty<int> Age = new CustomProperty<int>(0);
public CustomPropertyAccess() { }
}
private void button1_Click(object sender, EventArgs e)
{
CustomPropertyAccess CPA = new CustomPropertyAccess();
CPA.Name.Value = "lino";
CPA.Age.Value = 25;
MessageBox.Show(CPA.GetType().GetField("Name").FieldType.GetProperty("Value").GetValue(null , null).ToString());
}