2011-03-09 3 views

답변

5

당신이 Type 클래스의 GetProperty를() 메소드를 사용할 수 있습니다 http://msdn.microsoft.com/en-us/library/kz0a8sxy.aspx

Type t = typeof(MyType); 
PropertyInfo pi = t.GetProperty("Foo"); 
object value = pi.GetValue(null, null); 

class MyType 
{ 
public static string Foo 
{ 
    get { return "bar"; } 
} 
} 
4

사용 Type.GetProperty() BindingFlags.Static과 함께합니다. 그런 다음 PropertyInfo.GetValue().

3

다른 속성 (예 : the answer to this question 참조)을 얻는 것처럼.

GetValue을 호출 할 때 null을 대상 개체로 제공한다는 점만 다릅니다.

관련 문제