0

I am trying to convert a string which could be anywhere from 2 to 96 digits long and store it as an integer, but everything I've tried leads to OverflowException. Is there a certain way to convert a very large number?

My code converts a string input by the user into an array of the corresponding ASCII values of the each character in the input and then concatenates all the values of the array into a string, which I am then trying to convert into an integer.

Any help is greatly appreciated. Thanks!

JBall
  • 1
  • [BigInteger](https://learn.microsoft.com/en-us/dotnet/api/system.numerics.biginteger) – Jimi Mar 13 '20 at 03:32
  • Check out https://learn.microsoft.com/en-us/dotnet/api/system.numerics?view=netframework-4.8 BigInteger may be useful – Rob L Mar 13 '20 at 03:33
  • using System.Numerics; namespace BigNumTest { class Program { static void Main(string[] args) { var myBigNumber = "123456789213646578912345678912345600"; var myBigInt = BigInteger.Parse(myBigNumber); myBigInt = myBigInt + 99; Console.WriteLine(myBigInt); } } } – Rob L Mar 13 '20 at 03:41

0 Answers0