2015-10-22 70 views
-1

有人可以請解釋一下,爲什麼System.Type中的GetProperty方法對於聲明爲「內部」但適用於「公共」的屬性返回null。GetProperty方法返回null C#.Net

internal class Test{  
    public string ALocal { get; set; } 
    internal string SLocal { get; set; }} 

var test = new Test(); 
var testType = test.GetType(); 

var aProp = testType.GetProperty("ALocal"); => returns string Type 
var sProp = testType.GetProperty("SLocal"); => returns null 

我瞭解內部或公共修飾符之間的差異。

+0

參見[這個問題](http://stackoverflow.com/questions/7575577/how-do- i-iterate-through-internal-properties-in-c-sharp) –

回答