C#

C#

By DeepSource

Explicit mention of array size is redundant when array is initialized CS-R1045

Anti-pattern
Autofix

Consider dropping the array size when it is initialized explicitly using an initializer. This makes the syntax more concise.

Examples

Bad Practice

var arr = new int[5] {1, 2, 3, 4, 5};

Recommended

var arr = new[] {1, 2, 3, 4, 5};