我注意到.NET核心不允许,myObj.GetType().GetProperties()因为没有GetProperties方法存在.有没有其他方法通过反射获得类的属性?
我试图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应用程序.