Is it possible to dynamically compile and execute C# code fragments?

后端 未结 6 1740
伪装坚强ぢ
伪装坚强ぢ 2020-11-21 07:10

I was wondering if it is possible to save C# code fragments to a text file (or any input stream), and then execute those dynamically? Assuming what is provided to me would c

6条回答
  •  -上瘾入骨i
    2020-11-21 07:19

    To compile you could just initiate a shell call to the csc compiler. You may have a headache trying to keep your paths and switches straight but it certainly can be done.

    C# Corner Shell Examples

    EDIT: Or better yet, use the CodeDOM as Noldorin suggested...

提交回复
热议问题