How to run C # code using C # code?

I asked earlier about the same question , but that was in java ....
now for knowledge, I want to know ...

Is it possible to run one C # code with another C # code?

bcz I know that C # is very powerful, so there may be some way to do it.

+3
source share
3 answers

This is the same deal:

  • Compile the code, for example. usingCSharpCodeProvider
  • Run the code, for example. using reflection

If you download Snippy from the C # website in depth, you can see a small example of this - basically you enter snippets from C #, and it can compile and execute them for you.

+4
source

, , ; MS.NET, CSharpCodeProvider , , , , " " .

Mono, , REPL.

( ):

  // First setup the active using statements:
  Evaluator.Run ("using System;");

  Evaluator.Run ("Console.WriteLine (\"Hello, World\");
+4

There is a CodeDom namespace for this. Check out this article.

+1
source

Source: https://habr.com/ru/post/1751170/


All Articles