Welcome C# Interactive Window (or: Visual Studio Debugging Tips – #4)

TL;DR – Once you try the C# Interactive Window, you will never run another Console App just to try out an API.


You know how they say that if the only tool you have is a hammer, then everything looks like a nail? Well, this is especially true in the software industry. I once witnessed a guy debugging a .NET application with WinDbg  just because he is a guru of that tool. At that moment I thought to myself how happy he would be if he only knew the tools available to him with Visual Studio.

Anyway, enough with the jabber, I am here to make you fall in love with the C# interactive window that is available with Visual Studio 2015 update-1.

After finishing the update of you VS, navigate to:

View > Other Windows > C# Interactive

What you should see is a new window that looks like this:


Features, features and features…

Alright, after getting all the boring stuff out of the way, I want to show you what you can do with this. The whole set of features is explained on the official Microsoft GitHub account, so I wont cover everything but give you a taste of the most interesting ways you can use it in your day-to-day development.

    1. Multi-line support – you can write fully executable script by pressing ‘Shift+Enter’ for a new line, and for actual execution use ‘Ctrl+Enter’ when your script is ready. Consider this snippet:


    1. Reference external dlls – you can actually load an external dll to play with it’s APIs by using the #r command like this:
      This is seriously a powerful tool!


    1. Use interactive outside VS – you can run this environment even outside Visual Studio by simply executing  ‘csi’ in you Developer Command Prompt from VS 2015:interactive-csi


    1. Loading saved scripts – you can write a common script and load it in to the execution context by using the #load command. This is super cool when you have a script that is loading an entire environment for you that you can work with with specific APIs.


    1. Execution context – when the window initializes, you can create variables that will live until you type the  #reset command. For example try executing the following command, and use the myFile variable in your next commands:var myFile = new FileInfo(@"c:\users\shonn\desktop\myResume.txt");


    1. Navigation – You can navigate executed statements history by using ‘Alt+UpArrow’.


Go ahead and explore more features (believe me there are tons!), it is really awesome!

Feel free to leave a comment if this was helpful 🙂
Shonn Lyga.


About Shonn Lyga

Obsessed with anything and everything in Software Engineering, Technology and Science
This entry was posted in .NET, Debugging and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s