JetBrains Rider 2017.2 Help

Code Inspection: Redundant explicit array size specification in array creation

If you initialize an array by enumerating the values of its elements, there is no need to specify its size because the size is supplied by the number of elements in the array initializer.

JetBrains Rider suggests a quick-fix that removes the explicit specification of the array size.

Suboptimal codeAfter the quick-fix
var x = new int[3] { 1, 2, 3 };
var x = new int[] { 1, 2, 3 };
Last modified: 27 December 2017

See Also