ReSharper 2024.3 Help

Code inspection: Convert constructor into member initializers

When you have a parameterless constructor that only initializes properties, you can get rid of the constructor and initialize the properties at their declaration points. This simplifies the code and makes it easier to see the initial values for properties at a glance.

public class BlogPost { public BlogPost() { Name = "Empty"; } public string Name { get; set; } }
public class BlogPost { public string Name { get; set; } = "Empty"; }
Last modified: 04 June 2024