c#中使用java的BigInteger

     在c#中沒有BigInteger這個類,有時候感覺很不方便,其實在C#中是可以調用java中的的某些類的,調用的方法如下:首先添加引用vjslib(這其實是J#的類),然後我們就可以通過使用BigInteger中的類了,下面是我寫的一小段程序,實現兩個大數的相乘。

using System;
using System.Collections.Generic;
using System.Text;
using java.math;

namespace BigIntegerTester
{
    class Program
    {
        static void Main(string[] args)
        {
            BigInteger a = new BigInteger(Console.ReadLine());
            BigInteger b = new BigInteger(Console.ReadLine());
            Console.WriteLine(a.multiply(b));
        }
    }
}

     簡單吧,其他的類也可以用相似的方式進行調用。

posted on 2008-11-23 22:34  小橋流水  阅读(923)  评论(2编辑  收藏  举报

导航