Reflection.Emit better than GetValue & SetValue :S

后端 未结 5 1511
说谎
说谎 2020-12-13 21:03

I\'ve been told to use Reflection.Emit instead of PropertyInfo.GetValue / SetValue because it is faster this way. But I don\'t really know what stuff from Reflection.Emit a

5条回答
  •  天涯浪人
    2020-12-13 21:31

    The purpose of Reflection.Emit is completely different from that of PropertyInfo.Get/SetValue. Via Reflection.Emit, you can directly emit IL code, for example into dynamically compiled assemblies, and execute this code. Of course, this code could access your properties.

    I seriously doubt that this will be much quicker then using PropertyInfo in the end, and it's not made for this purpose either. You could use Reflection.Emit as the code generator for a small compiler, for example.

提交回复
热议问题