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.

Explore More

Working With File Class In C#

In C#, ‘File’ class provides many static methods for moving, copying, and deleting files. These Static methods involve moving a file and copying and deleting a file also. Let’s check

How to Read a Text File in C#

In C# ‘File’ class provides static methods to read given text file data. The File.ReadAllText() method opens a text file, reads all the text present in the file into a

C# | How to use Interface references

In C#, you’re permitted to make a reference variable of an interface type or in other words, you’re permitted to form an interface reference variable. Such kind of variable can