2

So let's say I'm debugging the following method in a C# program:

int MyMethod()
{
   return 0;
}

Is there any way (for example in the watch window?) to execute a statement that will make MyMethod return the value of 1? Or alter the returned value in any way not touching the code at all? (This means that adding int i = 0; return i; and then changing the value of i with the debugger is not an option)

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Gaspa79
  • 5,488
  • 4
  • 40
  • 63
  • What are you trying to achieve? What is the BIG picture? – Matsmath May 30 '16 at 19:12
  • Exactly what I said. Make the debugger return an arbitrary value at runtime when the code says different. The big picture is that I can't change the code at all, but I can step through it. Can't add an intermediate variable say int i = 0; return i; and then modify i at runtime. – Gaspa79 May 30 '16 at 19:13
  • 1
    You can barely read return value - http://stackoverflow.com/questions/268048/can-i-find-out-the-return-value-before-returning-while-debugging-in-visual-studi, one of the answers there shows how sometimes you can [change it](http://stackoverflow.com/a/13132495/477420). – Alexei Levenkov May 30 '16 at 19:18
  • @AlexeiLevenkov the signpost might point to the wrong duplicate (as the referenced one does not really address C#). – Matsmath May 30 '16 at 23:58

0 Answers0