What you are referring to is a REPL.
A read–eval–print loop (REPL), ...is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user.
You can check out CSharpRepl on GitHub.
Source: