Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use BigInteger in VS 2010

I have been trying to use the BigInteger type, that is supposedly new in .NET Framework 4.0.

I don't seem to be able to get to it, and get an error when trying to reference it via Using System.Numerics.

Any idea what I'm doing wrong? Sorry if this is a stupid question...

like image 456
Halfdan Faber Avatar asked Nov 26 '10 00:11

Halfdan Faber


2 Answers

  1. Add a reference to the System.Numerics assembly to your project.

    a. In Solution Explorer, right-click the project node and click Add Reference.

    b. In the Add Reference dialog box, select the .NET tab.

    c. Select System.Numerics, and then click OK.

  2. Add a using directive importing the System.Numerics namespace:

    using System.Numerics;
    
  3. Use the BigInteger structure:

    var i = new BigInteger(934157136952);
    
like image 150
dtb Avatar answered Oct 06 '22 00:10

dtb


Did you add a reference to System.Numerics?

Right click on References -> Add Reference -> .NET tab -> System.Numerics -> OK

like image 44
Brian R. Bondy Avatar answered Oct 06 '22 00:10

Brian R. Bondy