Sometimes during debugging of your code, you have to modify
value for a particular variable. In a typical debugging session, you will first
stop that debugging, make code changes and then start debugging
again. But there are few other quick ways of modifying variable values without
stopping and re-starting debugging session. Let’s say you have a Point class with an
overloaded + operator as shown below.
class Point
{
public int X { get; private set; }
public int Y { get; private set; }
public Point(int x, int y)
{
this.X = x;
this.Y = y;
}
public static Point operator +(Point P1, Point P2)
{
return new Point(P1.X + P2.X, P1.Y + P2.Y);
}
}
Let’s say we want to modify the value of P1.X to something
else in the overloaded + operator. I will show you couple of ways of doing it without stopping
debugging session. First is from Locals window. You can not only
inspect local variables through this window but you can also modify values for
these variables. In order to modify the value of variable, you have to right
click and then select Edit Value option as shown below.

After selecting this menu option, we modify the value
of P1.X to 100. Once this change is made, the updated value will be shown in
red within Locals as shown below.

Another way of changing variable values is by writing code
in Intermediate Window. As shown in figure below, we have updated the value of
P1.X in Intermediate Window by writing P1.X = 500; in Intermediate window. This change is reflected in Locals window as
well.

One more way of doing it is using Datatips. If you hover your mouse the P1.X in the code, a small window will appear showing the value of this variable (as shown in figure below).

At this point, you can just double click on the value 10 and modify to whatever value you need. As shown in figure below, I changed the value to 900. Once this value is modified, it will be displayed in red within the data tip and in Locals window.

I hope you will find this tip helpful.
History
First Version: 17 August 2012
Second Version: Update to include DataTips based on feedback from varun_minpal.