开发者

See return value in C#

开发者 https://www.devze.com 2022-12-28 22:07 出处:网络
Consider the following piece of code: As you can see we are on line 28. Is there any way to see the return value of the function at this point, without letting the code return to the caller functio

Consider the following piece of code:

See return value in C#

As you can see we are on line 28. Is there any way to see the return value of the function at this point, without letting the code return to the caller function?

Foo.Bar() is a function call which generates a unique path (for example). So it's NOT constant.

Entering ?Foo.Bar() in the immidiate window doesn't work either, since that reevaluates the code:

?Foo.Bar()
"80857466"
?Foo.Bar()
"2146375101"
?Foo.Bar()
"1106609407"
?Foo.Bar()
"792759112"

In VB.NET it's possible by entering the function's name in the Watch, which will then threat it as a variable.

But in C# this is not possible, any other tips?

开发者_运维问答

PS: rewriting is not an option.


Answer found here: VS get returned value in C# code?

It is actually visible. Debug + Other Windows + Registers. Look at the value of EAX (RAX in x64). The value of simple integral types are returned in the EAX register. Long in EDX:EAX. Floating point in STx (XMM00 in x64).


Assuming you are using visual studio, you could use the Immediate window. If you type Foo.Bar(); in the Immediate window you will get the result you are after, if you don't want it to re-evaluate stick a break point in the appropriate spot IE either before it evaluates the first time or in Foo.Bar() itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号