As is, this will not return anything, since the default binding is only for public fields.
As well, the derived type is not inferred from the base type
FROM
FieldInfo[] fields = derived.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
It returns outputvar. I just checked LINQPad.
If I change the derived type to be obtained from the base type, then I can get both fields with:
FieldInfo[] fields = derived.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Concat(derived.GetType().BaseType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)).ToArray();
source share