JetBrains Rider
 
2024.3
Get JetBrains Rider

Code inspection: Use collection expression syntax

Last modified: 14 November 2024

Collection expressions introduced in C#12 provide a more concise syntax for collection initializations. Therefore, JetBrains Rider suggests using this syntax instead of the legacy collection initializer syntax:

If the collection initializer is immediately followed by Add() calls on the collection, the quick-fix will also integrate these calls into the collection expression: