Rider 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 array type explicitly. Such arrays are convenient when you initiate objects or collections.

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

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

See Also