JetBrains Rider 2023.3 Help

Code Inspection: Append to collection expression

If a collection expression is immediately followed by Add() calls on the collection, JetBrains Rider suggests improving the structure and readability of the code by integrating the added items into the collection expression:

List<string> numbers = ["one", "two"]; numbers.Add("three"); numbers.Add("four");
List<string> numbers = [ "one", "two", "three", "four" ];
Last modified: 12 December 2023