I have a requirement where in on each step of code execution, I want to access Locals window variables programatically in C#/Visual Studio. Is there a way to do this ?
Is there a particular command to get those variables just like we have something for checking the call stack "Environment.StackTrace" ?
Locals Window in Visual Studio image
While debugging we can see all variables of current scope in Locals window -> So I wanted to write a piece of code which on each line tells me the status of current locals. Example:
void function()
{
var x = 0, y = 0;
printLocals()
x = 1;
printLocals()
y = 1;
printLocals()
}
So here, printLocals() method is a placeHolder which should give me all local variables, just as they are getting displayed in locals window