C# Error CS1021 – Integral constant is too large

C# Error

CS1021 – Integral constant is too large

Reason for the Error & Solution

Integral constant is too large

A value represented by an integer literal is greater than .

The following sample generates CS1021:

// CS1021.cs  
class Program
{
    static void Main(string[] args)
    {
        int a = 18_446_744_073_709_552_000;
    }
}  

The following code also generates CS1021:

using System.Numerics;

class Program
{
    static void Main(string[] args)
    {
        var a = new BigInteger(18_446_744_073_709_552_000);
    }
}

For information about how to instantiate a instance whose value exceeds the range of the built-in numeric types, see the section of the reference page.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...