小编Phi*_*ges的帖子

没有调试的C#64位发布版本与调试启动时的行为不同(BigInteger)

我是C#的新手并且遇到了以下代码的问题(我的目标框架为4.5,我添加了对System.Numerics的引用):

using System;
using System.Numerics;

namespace Test
{
    class Program
    {
        static BigInteger Gcd(BigInteger x, BigInteger y)
        {
            Console.WriteLine("GCD {0}, {1}", x, y);
            if (x < y) return Gcd(y, x);
            if (x % y == 0) return y;
            return Gcd(y, x % y);
        }

        static void Main(string[] args)
        {
            BigInteger a = 13394673;
            BigInteger b = 53578691;
            Gcd(a, b);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当通过调试启动发布版本时(Visual Studio中的F5 - 以及程序结束时的断点,以便我可以看到输出),我得到以下输出:

GCD 13394673, 53578691
GCD 53578691, 13394673
GCD 13394673, 13394672
GCD 13394672, 1
Run Code Online (Sandbox Code Playgroud)

但是,在没有调试(Ctrl-F5)的情况下启动发布版本时,我得到以下内容:

GCD …
Run Code Online (Sandbox Code Playgroud)

c# 64-bit biginteger

9
推荐指数
1
解决办法
376
查看次数

标签 统计

64-bit ×1

biginteger ×1

c# ×1