开发者

how to access all public variables in the class sequentially?

开发者 https://www.devze.com 2022-12-14 23:24 出处:网络
开发者_JAVA技巧I want to access all public variables declared in the class sequentially. Which is the best way to do it?FieldInfo [] fields = typeof(YourClass).GetFields(BindingFlags.Public | BindingF
开发者_JAVA技巧

I want to access all public variables declared in the class sequentially. Which is the best way to do it?


FieldInfo [] fields = typeof(YourClass).GetFields(BindingFlags.Public | BindingFlags.Instance);

this will return FieldInfo on all the public fields


typeof(MyClass).GetMembers()
0

精彩评论

暂无评论...
验证码 换一张
取 消