Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max integral type in C#

Tags:

c#

types

I can't seem to find an integral type that this will work on:

string foo = "9999999999999999999999999999999999999999999999999999999";

long value;
if(long.TryParse(foo, out value))
{
   // do something
}
like image 617
Joe Avatar asked Apr 13 '11 18:04

Joe


2 Answers

In .NET 4 you can use System.Numerics.BigInteger which has a TryParse method.

See: http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx

like image 79
user127.0.0.1 Avatar answered Oct 06 '22 03:10

user127.0.0.1


Yes, .NET 4.0 introduces BigInteger which is arbitrarily large and supports TryParse, of course.

http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx

like image 32
James Michael Hare Avatar answered Oct 06 '22 03:10

James Michael Hare