Reading All possible C # array initialization syntaxes I wondered why C # always displays an array int/Int32where there is a smaller data type, such as byteor shortwould be enough.
new[] { 30, 130, 230 }
new[] { -1, 125, -119 }
new[] { -31647, -1337, 23456}
In the question mentioned, Eric Lippert claims that the “best type” is used - see below, but how is the intbest type possible? If we are going to outwit, why not use long, then?
The type of an array element is inferred by calculating the best type, if there is one, from all given elements that have types. All elements must be implicitly convertible to this type.
I would suspect that processing 8 or 16-bit data types may be faster than 32-bit structures, for example. when using SIMD, where four instances bytecan fit into the register space of one int/Int32. I know that SSE instructions are not (widely) used by the JIT compiler , but this use inteverywhere "ensures that this does not help when the JIT Compiler includes such optimizations.
Can someone elaborate on these facts and tell why he always resorts to int?
// Edit //
I don’t care about the specification, which prescribes that a literal without a prefix should be considered int. To rephrase the question:
, ? ?
, - (SIMD).