存储号码没有限制(无限)的.NET语言 [英] Store a number with no limit (infinite) in .NET Languages

查看:151
本文介绍了存储号码没有限制(无限)的.NET语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我要存储在一个类中的无限数量的元件,为Excel做的薄片张数(受​​计算机的存储器中)。

Suppose I want to store a unlimited number of elements in a class, as Excel do with the number of Sheets (limited by the memory of the computer).

哪个是保持用于获取元素的索引的方式或数字类型?

Which is the way or the number type to hold the index used to get the elements?

推荐答案

如果你想存储的任意大的整数,你可以使用的 的BigInteger

If you want to store an arbitrarily large integer you can use BigInteger.

public BigInteger Index{ get; set; }

请注意,你必须先添加一个引用 System.Numerics DLL。

Note that you have to add a reference to the System.Numerics dll first.

它不同于其他整型在.NET Framework具有由所指示的范围的 MINVALUE 的MaxValue 属性。

It differs from other integral types in the .NET Framework which have a range indicated by their MinValue and MaxValue properties.

由于它没有上限或下限的 OutOfMemoryException异常可以抛出,导致一个的BigInteger 值的任何操作增长过大。

Because it has no upper or lower bounds an OutOfMemoryException can be thrown for any operation that causes a BigInteger value to grow too large.

这篇关于存储号码没有限制(无限)的.NET语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆