Integral constant is too large (CS1021) - How to put 1000 extremely big (70+ digits) integers in an array?

后端 未结 2 1922
醉酒成梦
醉酒成梦 2021-01-14 21:46

I\'m using the software SharpDevelop (C#).

I\'ve created a list of integers (array) like this:

int[] name = new int[number-of-elements]{elements-sepa         


        
2条回答
  •  醉话见心
    2021-01-14 22:05

    The error does not mean that you have too many integers in your array. It means that one of the integers is larger than the maximum value representable in an int in C#, i.e. above 2,147,483,647.

    If you need representation of 70-digit numbers, use BigInteger:

    BigInteger[] numbers = new[] {
        BigInteger.Parse("1234567890123456789012345678")
    ,   BigInteger.Parse("2345678901234567890123456789")
    ,   ...
    };
    

提交回复
热议问题