Using GetProperties() with BindingFlags.DeclaredOnly in .NET Reflection

后端 未结 5 1812
天涯浪人
天涯浪人 2020-12-01 07:02

If I use

sometype.GetProperties();

I get all of the properties from the type and it\'s parent. However I only want to retrieve the proper

5条回答
  •  庸人自扰
    2020-12-01 07:57

    From the MSDN site.

    Default (member) Specifies no binding flag.

    You must specify Instance or Static along with Public or NonPublic or no members will be returned.

    Hence unless you specify the binding flags you get nothing.

提交回复
热议问题