JetBrains Rider 2018.2 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.

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

Suboptimal code

After the quick-fix

var x = new int[] { 1, 2, 3 };

var x = new[] { 1, 2, 3 };

Last modified: 21 December 2018

See Also