C# Reflection get Field or Property by Name
Change this line:
MemberInfo info = type.GetField(memberName) ?? type.GetProperty(memberName);
to this:
MemberInfo info = type.GetField(memberName) as MemberInfo ??
type.GetProperty(memberName) as MemberInfo;
because there's no implicit cast to the base class when using the ternary operator like that. The ternary requires that the types of all outputs be the same.