“Execute in Interactive” feature is great addition with the new Visual Studio 2015 Update. Previously I shared several posts on C# Interactive Window , discussed about how to work with it ? How to execute scripts using interactive Window ? . Recently I shared another quick tip on Calling current project methods from C# Interactive Window in Visual Studio 2015 ? which talks about interacting with current projects. While this works well, you need to load the assembly or the executive file first before you execute any code inside the Interactive Window.
Well, this is now more simpler and you can interact with your current project code easily by sending them to interactive Window. The recent updates of Visual Studio 2015 now support “Executive in Interactive” by which you can send the code directly to Interactive Window.
- Select the Line or Block of Code which you want to send in Interactive Windows
- Right Click, and from the Context menu select “Execute in Interactive’’”
This will send the code directly to Interactive Command Windows.
You can now start using names inside interactive Windows.
Here is the interesting facts, if your code has executable, for an example writing something to Console, the Interactive Window will execute it automatically.
For an example you select the below code block and then choose “Execute in Interactive”
This will not only push the code to Interactive Window, it will also execute the same as given in below snapshot.
All in all, this is a great addition and can help developer quickly push some code to interactive window and test them out.
Hope this helps