How to use Runtime Objects in Watch Window during debugging in Visual Studio ?

During debugging in visual studio we generally used watch window to explore the objects, values, properties and other nested objects as a tree structure. Most of the time we used watch window to only view the values or change the current object properties values to see the effects of changed object during debugging. And most of the time we debug with the context of current object, object values etc but what if, If you need a brand new object instead of object value. This scenarios will come when you want to compare some existing value with some new object values. You can instantiate a new object by just type new ClassName(), which will generate you the new instance of your class as shown in below picture.

newobj1

But, you need to take help of Immediate window if you want to declare a new object to used it further

newobj2

As shown in above image you can create new object and used it immediate window.

Why do we need to take help of Immediate window to declare the object ? because Immediate window does not allow you declaration statements.

newobj3

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

2 Comments to “How to use Runtime Objects in Watch Window during debugging in Visual Studio ?”

Comments are closed.