相关疑难解决方法(0)

获取.NET核心中的类的公共属性

我注意到.NET核心不允许,myObj.GetType().GetProperties()因为没有GetProperties方法存在.有没有其他方法通过反射获得类的属性?

c# .net-core

9
推荐指数
2
解决办法
9933
查看次数

Type.GetProperties()在Release中不起作用

我试图FontWeights使用反射在C#中获取类的属性.

var properties = typeof(FontWeights).GetProperties();
var dialog = new MessageDialog("Number of weights: " + properties.Length);
await dialog.ShowAsync();
Run Code Online (Sandbox Code Playgroud)

使用Debug配置构建时,上面的工作正常.但是,使用Release时,找不到任何属性.

为什么会这样?有办法解决吗?

这是一个UWP应用程序.

c# system.reflection win-universal-app

3
推荐指数
1
解决办法
285
查看次数