Not that I would ever need to do this, but I want to understand how it works/doesnt work. I googled quite a bit for max length of an array and can't really find anything.
long[] hugeArray = new long[long.MaxValue];
//No Exceptions
Console.WriteLine("Init");
//Overflow Exception
Console.WriteLine(hugeArray.LongLength.ToString());
hugeArray = new long[int.MaxValue];
//OutOfMemoryException
Console.WriteLine( hugeArray.Length.ToString());
And I guess a follow up question would be, if there is a limit and I am initizlizing outside that limit, why no exception when creating only when using? And is this something the compiler should catch?