2011-03-09 82 views

回答

5

你可以使用Type类的getProperty()方法:)与BindingFlags.Static 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(。然后PropertyInfo.GetValue()。

3

就像你会得到任何其他财产(例如,看看the answer to this question)。

唯一的区别是当您拨打GetValue时,您会提供null作为目标对象。