相关疑难解决方法(0)

如何在c#中迭代内部属性

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; }
}
Run Code Online (Sandbox Code Playgroud)

我可以使用以下循环遍历属性,但它只显示公共属性.我需要所有的属性.

foreach (PropertyInfo property in typeof(TestClass).GetProperties())
{
    //do something
}
Run Code Online (Sandbox Code Playgroud)

c# reflection properties access-modifiers

26
推荐指数
3
解决办法
2万
查看次数

标签 统计

access-modifiers ×1

c# ×1

properties ×1

reflection ×1