C#中的最大整数类型

问题描述

| 我似乎找不到可以使用的整数类型:
string foo = \"9999999999999999999999999999999999999999999999999999999\";

long value;
if(long.TryParse(foo,out value))
{
   // do something
}
    

解决方法

在.NET 4中,可以使用具有TryParse方法的System.Numerics.BigInteger。 请参阅:http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx     ,是的,.NET 4.0引入了BigInteger,它很大,并且当然支持TryParse。 http://msdn.microsoft.com/zh-CN/library/system.numerics.biginteger.aspx     ,没有一种原始类型适用于此。但是.NET 4中引入了一个新的BigInteger类。 http://weblogs.asp.net/gunnarpeipman/archive/2009/05/23/net-framework-4-0-introducing-biginteger.aspx     ,您正在寻找BigInteger。