开发者

Regarding the use of reflection in dotnet and the performance

we know that with the help of reflection we can create instance of a class dynamically at run time and can call the method 开发者_开发技巧of the class very easily. so this point reflection is late binding because action is taken at run time. so i just want know reflection is faster or not. what is the performance of reflection. is it good or bad...is it resource hungry. please discuss. thnks.


Technically speaking reflection is a performance hit. But if you're doing something that needs it then you have to use it. If you can go without it, avoid it.

EDIT

To further emphasize, reflection is neither good or bad. Its in the Framework because there's very legitimate reasons to use it. That said, 90% of the time that I see someone using reflection they're trying to do something the hard way, not knowing the easy route. Often its because they don't know about generics.


Generally, the performance of reflection is worse than when you do the same thing without reflection. But whether it is too slow for you depends on what your performance requirements are (do you need it to be fast) and what exactly are you doing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜