The C# program that executes("maybe interpreterpath") another program. Is it possible?

Is it possible to implement such a program that would read a specific file format and to execute instructions written in them?
well, for example:
var answer = Console.ReadLine();
if (answer == "1") {

__this subroutine displays the message "enter X" and prints to the console the square of this number,__

And to add these subroutines to the main program without interference and to recompile the main program(Main)?

At the moment there is such a simple project:

And I would like to add other routines in separate folder in ./src and it does not touch the files that lie at the root of the project, namely(BaseProgram.cs Executor.cs, Program.cs)

UPD 1: Surely you need to draw some lua ?
June 10th 19 at 15:44
4 answers
June 10th 19 at 15:46
thank you for your appreciation ))

briefly flew thought - do scription of a specific topic

the fact that it is more convenient to write C#, more often than not it is difficult to compile, and include in the static part of the project

many other languages, if the scripting can be and more convenient, and more efficient in terms of support/maintenance

but it can be pretty fast to clarify for themselves - to ask loved one search phrase - scription .net

good luck! - Amaya.Mayert commented on June 10th 19 at 15:49
Oh yeah.. in the environment of Windows, the same powershell more than an effective means of dotNet scripting as above (directly from a script can pull as system libs/classes and their load) and from the inside - Amaya.Mayert commented on June 10th 19 at 15:52
June 10th 19 at 15:48
Almost all scripting languages written in something that interpreterpath something.
Of course you can write in any programming language program that will run the code in the file - maybe you will write another programming language, or the language of simple macros.

lua is a ready-made solution in order to insert in his programme the engine that will execute lua scripts. Depends on what you want your program to know how to execute lua or know how to perform your own set of instructions.
tell me please, if I'm going to compile these scripts into a separate DLL, then will they be able to get access to the context from which the program connects the DLL and work for example with controls on the form if this is a WinForms\WPF app ? - Amaya.Mayert commented on June 10th 19 at 15:51
If you write a program, you can program the behavior of all its parts.
There is no magic, which is the script that does not have a corresponding command, maybe to do something unintended.
Stipulate in your winforms methods to control outside, and write in your new scripting language commands to access those methods will work.

Programming is not magic, it's tedious work, where it is necessary to describe ALL possible behavior of every detail. - Amaya.Mayert commented on June 10th 19 at 15:54
Thanks , it seems now it became clear.
And let me clarify another point-the output is all pretty simple:
Write a separate subroutine that manipulirovat data of the main program/ might even repaint.
In turn, the main program depending on the needs of the connects need the DLL(imports), for example, then calls the Execute function from this DLL and connected bind(passes in as arguments) it is necessary dependencies(controls/form/data, etc). - Annamae59 commented on June 10th 19 at 15:57
Read more about the API
it's not the fact that it is through the DLL you need to solve it. - Jeff28 commented on June 10th 19 at 16:00
June 10th 19 at 15:50
Is it possible to implement such a program that would read a specific file format and to execute instructions written in them?

I want to tell how you can implement a similar idea

And you do not know? To read the file, parse the words, depending on the words to carry the team.

And if you want the option to tie the plug-ins to your software, then look in the direction of load assemblies dynamically. Describe the interfaces should look like plug-ins and what services you provide plugins. Good luck.
The city of your lexical analyzer is too expensive) I think it's better in the runtime then compile subroutines and/or forkat their individual treedom/process - Amaya.Mayert commented on June 10th 19 at 15:53
Then here - Amaya.Mayert commented on June 10th 19 at 15:56
very interesting, I will try at leisure - Annamae59 commented on June 10th 19 at 15:59
June 10th 19 at 15:52
lua, ironpython.

For something your write an interpreter based on the grammar of your language)

Find more questions by tags C#