Search code examples
c#reflectionbindingflags

Does the Pipe in binding flags not represent an 'OR'


I am currently debugging in the immediate window:

-

This returns 0 properties:

type.GetProperties(BindingFlags.Instance)

This also returns 0 properties:

type.GetProperties(BindingFlags.Public)

But this returns both properties:

type.GetProperties(BindingFlags.Instance|BindingFlags.Public)

And so does this:

type.GetProperties(BindingFlags.Public|BindingFlags.Instance)

I would have thought that if it was an or then if both the bottom return true then so should the top two.

Could someone explain to me how this works please?


Solution

  • Please see documentation of GetProperties. You must specify visibility (Public/Private) and if it should be Static or Instance properties.