Int64 创建数字范围 [英] Int64 creating a number range
问题描述
我需要能够创建长度超过 19 位的数字范围.
I need to be able to creat number ranges that are 19+ digits long in sequence.
我尝试使用Enumerable.Range(120000003463014,50000).ToList();
I tried using Enumerable.Range(120000003463014,50000).ToList();
这适用于较小的数字,但使用上面的我得到一个错误,说它对于一个 int32 数字来说太大了.有没有办法用大数字(有时我什至使用 25 位数字长 15 位数字)创建一个连续范围.提前致谢
Which works for smaller numbers but using the above I get an error saying it is too big for an int32 number. Is there any way to create a sequential range with large numbers (15 digits long sometimes I would even used numbers 25 digits long). Thank you in advance
附言我当前问题的起始编号是128854323463014结尾 #128854323513013
P.S. my starting number for the current issue would be 128854323463014 Ending # 128854323513013
推荐答案
您可以创建自己的接受 long
的版本:
You can create your own version that accepts long
instead:
public IEnumerable<long> CreateRange(long start, long count)
{
var limit = start + count;
while (start < limit)
{
yield return start;
start++;
}
}
用法:
var range = CreateRange(120000003463014, 50000);
这篇关于Int64 创建数字范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!