ReSharper 2024.1 Help

Code Inspection: Redundant explicit array size specification in array creation

Category

Redundancies in Code

ID

RedundantExplicitArraySize

EditorConfig

resharper_redundant_explicit_array_size_highlighting

Default severity

Warning

Language

C#, VB.NET

Requires SWA

No

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.

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

var x = new int[3] { 1, 2, 3 };
var x = new int[] { 1, 2, 3 };
Last modified: 12 April 2024