Why is "long" being allowed as array length in C#?

Because the specification says so in section 7.6.10.4:

Each expression in the expression list must be of type int, uint, long, or ulong, or implicitly convertible to one or more of these types.

This is most likely to easily allow creation of arrays larger than 2 GiB, even though they are not supported yet (but will be without a language change once the CLR makes such a change). Mono does support this, however and .NET 4.5 apparently will allow larger arrays too.

Regarding array length being an int by the way: There is also LongLength, returning a long. This was in .NET 1.1 and probably a future-proofing change.


why long is allowed as array length?

Answer is: long in .net means Int64

And array indexing can be Int64 according to specification.

2nd question: Why overflowexception is showing?

Because any single object can not be allocated more than 2GB of memory.