When do you use reflection? Patterns/anti-patterns

前端 未结 17 2259
旧时难觅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条回答
  •  长情又很酷
    2020-12-02 10:36

    There is no hard and fast rule. Basically, you don't use reflection without a good reason. Use reflection when you can't do what you want without it, or when your code would be much longer or more difficult to understand without reflection.

提交回复
热议问题