There’s more to the Visual Studio Immediate Window than you thought

There’s a window in Visual Studio which enable you to run code regardless of where and what you’re currently debugging. That magical windows is known as the Immediate window. To use it all you need to do is write valid code – such as System.Console.Write(“Hello”) and presto:


Countless developers have used this window during debugging to run code snippets and even countless speakers have used this windows to show cool tricks. But did you know that the same window can be used to selectively debug your code while writing it – without firing the debugger and stepping through countless lines just to find out you’ve forgotten to check for a null?

For example in the LinqAnalyzer project which we’ve used to find which LINQ API developers use the most – there’s a method which we’ve hacked together to parse command line arguments (called ParseArgs). The problem is that parsing strings is not trivial and we had quite a few exceptions thrown from it.

Instead of throwing various arguments at that method, we’ve used the Immediate window to quickly debug a few cases – which is simple. Just open the Immediate window (it’s under Debug->Windows). Put a breakpoint at the beginning of the method and write the following code: Program.ParseArgs(new[]{“1000”}); 


And the debugger kicks in running your method – and as you can tell, with a full OzCode support.