When do you use reflection? Patterns/anti-patterns

前端 未结 17 2263
旧时难觅i
旧时难觅i 2020-12-02 09:58

I understand the reflection API (in c#) but I am not sure in what situation would I use it. What are some patterns - anti-patterns for using reflection?

17条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 10:39

    When you want to improve performance of late-bound objects. You can emit the code necessary to call bound types directly, and then call through your emitted method. Although you cannot perform calls as speedily as with early binding, you will perform better than late binding.

提交回复
热议问题