It is a Read-Evaluate-Print-Loop (REPL) editor, where we can enter C# statements and execute immediately. It helps to learn APIs, play with C# features, check quick output without creating any console/test projects and experiment with other .NET technologies by providing you an immediate result. We can open it in VS 2015 from View -> Other Windows -> C# Interactive.
After opening it, we can enter any C# statements. It has a full intellisense and tooltip support also.
Once we hit Enter, it will execute the code and return the result:
We can declare the methods and complex code with "for loops" and LINQ expressions, as well, as shown below:
We can include a namespace and it handles the errors (compile and run time) as well:
We can load an assembly (.dll or .exe) and call a method in it by using #r command, as shown below:
We can a select a piece of code in our project and execute in an interactive Window, as shown below:
Output
We can select a project in Solution Explorer and load into an Interactive Window, as shown below:
Loading a project in this way will load all other dependent assemblies as well:
Output
We can execute C# script files (.CSX), using #load command:
C# script file is just a bench of C# statements with the first line in the file as an entry point (no need of Main method), which can be executed from any non-Visual Studio environment.
We can get the history of the commands entered, by using Alt + UpArrow and Alt + DownArrow.
We can use #help to get the complete list of the supported commands in C# Interactive Window:
I am ending the things here. I hope, this article will be helpful for all.