Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Int64 creating a number range

I need to be able to creat number ranges that are 19+ digits long in sequence.

I tried using Enumerable.Range(120000003463014,50000).ToList();

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

P.S. my starting number for the current issue would be 128854323463014 Ending # 128854323513013

like image 547
Adam Strobel Avatar asked Sep 17 '25 11:09

Adam Strobel


1 Answers

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++;
    }
}

Usage:

var range = CreateRange(120000003463014, 50000);
like image 66
haim770 Avatar answered Sep 20 '25 02:09

haim770