Calling Methods using Watch Window

IN this post we will learn about the Calling Methods using Watch Window. Watch Windows is one of the most commonly used debugging tools with Visual Studio. We often explore nested objects, values, properties, and other objects in tree form. Most of us use the watch window to simply display the values ​​or change the current value of an object’s properties to see the impact of a changed object during debugging, but we can also You can call a method from the window monitor. If you are exploring certain objects in the view window, you can simply call any method for that object in the view window.

Calling Methods using Watch Window

As you can see in the image above, when you import a stud object, you can access all the properties and methods that the original object can access.

For example, you can pass the appropriate marks into the AddMarks() methods to get the result details, as shown in the image below.

Calling Methods using Watch Window

Here’s another tip, you can use the variable “temp” to store this data. But you need to declare the variable in the “Immediate Window”.

So just declare a variable in the “immediate window” and use it in the view window, as shown in the image below.

Must read:



Calling Methods using Watch Window

Additionally, you can also use the same variable to perform additional operations.

Calling Methods using Watch Window

When calling some methods from the watch window, make sure their execution time is sufficiently shorter (less than 10 seconds). Otherwise, you will receive an exception when the evaluation period expires.

I hope above will help. You can check more articles on our website under C# section HERE or you can also check same on Microsoft Docs too.

Leave a Reply

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