How can I evaluate C# code dynamically?

后端 未结 16 2144
[愿得一人]
[愿得一人] 2020-11-22 03:37

I can do an eval(\"something()\"); to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#?

An example of what I

16条回答
  •  一整个雨季
    2020-11-22 04:15

    You could do it with a prototype function:

    void something(int i, string P1) {
        something(i, P1, String.Empty);
    }
    
    void something(int i, string P1, string P2) {
        something(i, P1, P2, String.Empty);
    }
    
    void something(int i, string P1, string P2, string P3) {
        something(i, P1, P2, P3, String.Empty);
    }
    

    and so on...

提交回复
热议问题