Getting the public properties of a class in .NET core

前端 未结 2 466
遥遥无期
遥遥无期 2020-12-10 05:01

I notice that .NET core doesn\'t allow myObj.GetType().GetProperties() as no GetProperties method exists. Is there another way to obtain the proper

相关标签:
2条回答
  • 2020-12-10 05:16

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

    0 讨论(0)
  • 2020-12-10 05:18

    Just to sum up to anyone else, just adding using System.Reflection to the top of the page is not enough. You will have to add the System.Reflection.TypeExtensions NuGet package as described in the question comments.

    PM> Install-Package System.Reflection.TypeExtensions -Version 4.3.0

    0 讨论(0)
提交回复
热议问题