Where would you use C# Runtime Compilation?

前端 未结 7 1331
余生分开走
余生分开走 2021-02-20 05:34

I happened upon a brief discussion recently on another site about C# runtime compilation recently while searching for something else and thought the idea was interesting. Have

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-20 06:13

    At least one case you might use it is when generating dynamic code. For example, the framework is using this internally to generate XML serializers on the fly. After looking into a class at runtime, it can generate the code to serialize / deserialize the class. It then compiles that code and users it as needed. In the same way you can generate code to handle arbitrary DB tables etc. and then compile and load the generated assembly.

提交回复
热议问题