在.NET Core中获取类的公共属性 [英] Getting the public properties of a class in .NET core

查看:369
本文介绍了在.NET Core中获取类的公共属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到.NET核心不允许 myObj.GetType()。GetProperties(),因为没有 GetProperties 方法存在。

I notice that .NET core doesn't allow myObj.GetType().GetProperties() as no GetProperties method exists. Is there another way to obtain the properties of a class through reflection?

推荐答案

似乎还有 myObj。 GetType()。GetProperties()是有效的。我只需要使用System.Reflection 通过引入System.Reflection。

It seems that myObj.GetType().GetProperties() IS valid. I just had to bring in System.Reflection by using System.Reflection.

这篇关于在.NET Core中获取类的公共属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆