1

I'm declaring an array of 16bit signed integers whose elements may run into the millions. I've been declaring the array as type Long as I was thinking along the terms of element length instead of the limit of each individual element. Is it correct to declare the type of array according to element types?

Thanks

1
  • 2
    If all you need is 16 bits, why use a 64 bit value type? Commented May 18, 2012 at 15:45

1 Answer 1

6

The element type of an array has nothing to do with the type of the index.
C# arrays only support 32-bit int indexing.

You should use a short[].

Sign up to request clarification or add additional context in comments.

2 Comments

Ok, so if the number of elements exceeds 2^32, will I then get an overflow err?
@Mickey It sounds like arrays are not the tool you need.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.