How can I track a variable\'s values as they change, at runtime, in C#? I\'m interested in the same functionality that the debugger provides when I\'m tracing a variable thr
The only sensible way you could do that without the debugger would be: don't use a variable, but use a property, and (perhaps conditionally) add trace to the setter:
private int myValue;
public int MyValue {
get {return myValue;}
set {
SomeTraceMethod(myValue, value, ...);
myValue = value;
}
}
Obviously this cannot then be used for arbitrary fields/variables.