C# Interactive Window in Visual Studio 2015 Update 1

The C# Interactive window has been made available again in Visual Studio with the first update to 2015, this time as a REPL window. You can type or paste and execute C# code, and it includes support for adding references to external DLLs and using namespaces. The window is intended for rapid prototyping C# code.

It is available from Views > Other Windows > C# Interactive.
csrepl1

Here is a simple example where we declare an integer variable, increment its value and then print it.
csrepl3

You can write any C# code including lambdas and LINQ queries.
csrepl4
You can also define types and write functions.
csrepl8
csrepl9

If you want to use a namespace you must use the using directive just as you do in C#.
csrepl5

For references to additional DLLs (whether from the framework or custom) you use the #r command specifying the path to the module.
csrepl6
After you referenced a module you can use its namespaces and the types available there.
csrepl7

For a list of all commands use the #help command.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.