ReSharper 2024.1 Help

Code Inspection: Redundant explicit type in array creation

Category

Redundancies in Code

ID

RedundantExplicitArrayCreation

EditorConfig

resharper_redundant_explicit_array_creation_highlighting

Default severity

Warning

Language

C#

Requires SWA

No

Starting from C# 3.0, implicitly-typed arrays are supported. The type of an array instance is determined by the type of elements specified in the array initializer, so you do not need to specify the array type explicitly. Such arrays are convenient when you initiate objects or collections.

ReSharper suggests a quick-fix that removes the redundant type specification.

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