public class TestClass
{
public string property1 { get; set; }
public string property2 { get; set; }
internal string property3 { get; set; }
internal string property4 { get; set; }
internal string property5 { get; set; }
}
Tôi có thể lặp qua các thuộc tính bằng vòng lặp sau, nhưng nó chỉ hiển thị các thuộc tính công khai. Tôi cần tất cả các tài sản.Tôi làm cách nào để lặp qua các thuộc tính nội bộ trong C#
foreach (PropertyInfo property in typeof(TestClass).GetProperties())
{
//do something
}
Xem thêm http://stackoverflow.com/questions/16024006/how-do-i-look-up-the-internal-properties -of-ac-sharp-class-protected-protecte cho một biến thể cho việc này. – nawfal