how to get both fields and properties in single call via reflection?

后端 未结 5 898
时光说笑
时光说笑 2020-12-03 05:05

I apologize if this is covered somewhere. I did research before posting!

okay, so question...I\'m using GetType( ).GetProperties, but it isn\'t returning simple inst

5条回答
  •  醉梦人生
    2020-12-03 05:35

    Using DLR (simple enough, if you know the member name at compile time):

    ((dynamic)obj).MyFieldOrPropertyName = myValue;
    

    If you only know the member name at run-time, I'd recommend FastMember, as Marc Gravell suggested.

提交回复
热议问题