我遇到了一些非常奇怪的问题.
我正在开发一些连接到webservices的类库.该库由桌面应用程序使用.
在我现在的代码中:
Int32 errorCode32 = errorCode;
Int32 errorTimeout = 300;
if (errorCode32.Equals(errorTimeout) == false)
{
System.Console.Out.WriteLine("aaa");
return;
}
Run Code Online (Sandbox Code Playgroud)
其中errorCode等于300.所以乍一看它是可见的,如果errorCode == 300而不是if语句中的代码不应该被执行,因为它被定义为仅当errorCode不等于300时执行.
到目前为止一切都很清楚,但现在整个乐趣开始了.
应用程序正在运行,并执行上述代码片段的方法.errorCode等于300,预期的结果是应用程序不会在if语句中执行任何代码,因为整个语句是false.但实际上应用程序进入"if"并立即跳转到"return"语句.System.Console.Out ...永远不会执行.如果我用"throw new SomeException()"替换clean"return"语句
Int32 errorCode32 = errorCode;
Int32 errorTimeout = 300;
if (errorCode32.Equals(errorTimeout) == false)
{
System.Console.Out.WriteLine("aaa");
throw new SomeException();
}
Run Code Online (Sandbox Code Playgroud)
我会得到相同的结果.应用程序进入if语句(注意:[errorCode32.Equals(errorTimeout)== false]在我的情况下为false),不执行Console.Out ...但抛出SomeException.
我多次重建了所有内容,删除了所有二进制文件,我甚至从磁盘中删除了整个项目,并从存储库再次检索到清理文件夹.
我很困惑,我甚至反汇编代码,看看会发生什么(即使我不是汇编程序的专家).但结果对我来说很奇怪.
反汇编代码如下:
50: Int32 errorCode32 = errorCode;
000000e5 mov eax,dword ptr [ebp-50h]
000000e8 mov dword ptr [ebp-54h],eax
51: Int32 errorTimeout = 300;
000000eb mov dword ptr [ebp-58h],12Ch
52:
53: if (errorCode32.Equals(errorTimeout) …Run Code Online (Sandbox Code Playgroud)