The Interactive Window in Visual Studio is a great utility to play around the code, language features, API’s and other .NET framework features. It is a REPL (Read–eval–print loop) that provides us an environment for live coding and evaluate expression or code snippet based on our inputs. The Interactive Window also support features like IntelliSense, syntax highlighting and navigating through executed commands.
We can also includes references to external dependency and also using namespaces like a normal Visual Studio Editor features.
To launch the Interactive window navigate through Views > Other Windows > C# Interactive.
Here is some of the common examples to start with…
Following example shows how we can define a basic variable, and write a basic C# code with the interactive window.
You will have full intellisense and tool tip support as similar to our main Visual Studio code editor.
You can also use the different language feature like I have used the string interpolation feature here – Easily format strings – String interpolation in C# 6.0
Now, weather it a simple C# code, complex code or even a LINQ you can execute live within the editor.
And of course you can do declare methods and use it. You might think what could the use of it ? Think in a way, you can write your method here, execute and test and finally when it is working fine with expected output you can move it to your main code.
The Interactive Window also support the using namespace, and once included then you can leverage all the feature for those assembly.
This tool also support error handling both compile and runtime as shown in below screenshot
well, to summarize, the Interactive window is for quick prototyping, checking some quick output of C# code without creating some new projects. This is really great utility available with Visual Studio and can help us to do quick code experiment. !
Hope this helps !
Pingback: Command Line C# Interactive Script Execution for Visual Studio
Pingback: Dew Drop – January 13, 2016 (#2166) | Morning Dew
Pingback: The Daily Six Pack: January 14, 2016 - Dirk Strauss
Pingback: Executing C# Scripts from Command Line or C# Interactive Windows in Visual Studio
Pingback: Visual Studio – Developer Top Ten for Jan 15th, 2016 - Dmitry Lyalin
Pingback: Use C# Interactive Window for your coding experiment in Visual Studio 2015 | Andreas Plahn Developer Blog
Pingback: Using multipurpose Command Window to execute things faster in Visual Studio
Pingback: Calling a current project method from C# Interactive Window in Visual Studio 2015 ?
Pingback: “Executive in Interactive”– Send to C# Interactive Window – Visual Studio 2015