Using the C# Interactive window to test code snippets in Visual Studio

If you want to test little snippets of code in Visual Studio before having to change your code and having to launch and debug your app, check out the Interactive window via the View -> Other Windows -> C# Interactive menu option.

The C# Interactive window is a REPL Editor, i.e. Read-Evaluate-Print-Loop and can be useful for things like

– checking date formats (shown below)
– declaring and testing methods
– testing strings – interpolation, substring, replace, trim etc.
– testing LINQ queries on declared collections

C# Interactive Window

Very nice introduction to the interactive window on the Microsoft Visual Studio channel on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *