ReSharper 2024.1 Help

Code Inspection: Redundant empty argument list on object creation expression

Category

Redundancies in Code

ID

RedundantEmptyObjectCreationArgumentList

EditorConfig

resharper_redundant_empty_object_creation_argument_list_highlighting

Default severity

Hint

Language

C#

Requires SWA

No

In C#, when you create a new instance of a class and immediately initialize it using a collection initializer (the part in the curly braces), you don't need to include the parentheses after the class name.

Therefore ReSharper suggests removing the redundant parentheses to make your code cleaner and more concise.

var words = new List<string>() {"one", "two"};
var words = new List<string> {"one", "two"};
Last modified: 15 April 2024