(E-Mail Removed) <(E-Mail Removed)> wrote:
> I need to invoke .getvalue and .setvalue on fieldinfo and propetyinfo
> objects. Even though they're both derived from MemberInfo, they don't
> share those two methods. I've finding myself writing the following
> types of structure over and over. Is there something I'm missing? Or
> some 'funky' 3.5 delegate/lambda expression way of doing this?
Bear in mind that they don't have the same parameters either -
FieldInfo.GetValue/SetValue doesn't take a set of arguments as one of
its parameters, whereas PropertyInfo does. In other words, it's hard to
see how they *would* share methods, even if there was some intermediate
common type (or an interface). I guess you could have PropertyInfo with
an overload of GetValue/SetValue which assumed no parameters.
You could always write a pair of utility methods to do this if you find
yourself doing it often though.
--
Jon Skeet - <(E-Mail Removed)>
Web site:
http://www.pobox.com/~skeet
Blog:
http://www.msmvps.com/jon_skeet
C# in Depth:
http://csharpindepth.com