0

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?

Kieran
  • 612
  • 6
  • 22
  • 1
    No, `|` and `&` has dual purpose depending on the type of operands, it can either be logical OR (if booleans are involved) or bitwise OR (if non-boolean ordinal types are involved). The latter applies in this case. Either way, for logical OR, `||` would be the short-circuit type. – Lasse V. Karlsen Mar 07 '19 at 12:04
  • 1
    In other words, this is combining enum flags bitwise to create a mask, it's not a boolean expression. – Lasse V. Karlsen Mar 07 '19 at 12:05

1 Answers1

2

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

Pablo notPicasso
  • 3,031
  • 3
  • 17
  • 22