ReSharper 2023.3 Help

Code Inspection: Redundant explicit type in array creation

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: 21 March 2024