Is your variable a property? If so you can write out to the immediate window in the set
Say you have a class such as
class MyClass
{
private int myVariable;
public int MyVariable
{
get
{
return this.myVariable;
}
set
{
System.Diagnostics.Debug.Print(value.ToString());
this.myVariable = value;
}
}
}
Then you could call code like this
MyClass mc = new MyClass();
mc.MyVariable = 1;
mc.MyVariable = 2;
And the output would be
1
2
The default setting in Visual Studio is for Debug.Print()
to write to the Output Window
. If you want it to go to the Immediate Window
instead go
Tools > Options > Debugging > General > Redirect all Output Window text to Immediate Window