简体   繁体   中英

Max integral type in C#

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
}

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

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

There is not a primative type that will work for that. But there is a new BigInteger class introduced in .NET 4.

http://weblogs.asp.net/gunnarpeipman/archive/2009/05/23/net-framework-4-0-introducing-biginteger.aspx

BigInteger是您正在寻找的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM