Visual Studio - How to change the return value of a method in the debugger?

前端 未结 6 451
轻奢々
轻奢々 2021-01-02 08:12

When I\'m debugging, I often have to deal with methods that does not use an intermediate variable to store the return value :

   private int myMethod_1()
            


        
6条回答
  •  生来不讨喜
    2021-01-02 08:49

    Why do you want to change the return value in the called method? You can easily change it on-the-fly in the Calling method. As soon as your function returns, you get the value returned and there you can change it.

       private int myMethod_1()
       {
          return 12;
       }
    //call would be something like this
    int x = myMethod_1();
    //Here you can change the value after the execution of the above line.
    

    Even if you are not storing return value in a variable, and you are directly passing it to some other method, even then you can change the value by stepping into that method and changing the argument value there. Am I missing something here?

提交回复
热议问题