Reflection to get public instance properties in UWP

こ雲淡風輕ζ 提交于 2019-12-12 04:26:02

问题


I am porting a Silverlight application to UWP. In my Silverlight app, i get the public instance properties:

Type t;
t.GetProperties(BindingFlags.Instance | BindingFlags.Public);

In UWP it look like the GetProperties(BindingFlags.Instance | BindingFlags.Public) method is no longer available. Is there another way to accomplish this in UWP?

thank you.


回答1:


From this MSDN source, you can do the following:

var props = t.GetTypeInfo().DeclaredProperties
                           .Where(x => x.GetMethod.IsPublic);


来源:https://stackoverflow.com/questions/38837778/reflection-to-get-public-instance-properties-in-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!