ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Member initialized value ignored

Last modified: 08 April 2024

If a constructor initializes a field from a parameter, it is not necessary to initialize the field at declaration. In the example below, ReSharper removes the initialization of _contents from its declaration because _contents is assigned a value in the constructor.

Initializing fields within a constructor is preferable for a number of reasons. For example, if there are more than one constructor, it enables you to initialize a field with different values. Generally, in case of complex logic the initialization inside a constructor is recommended.

ReSharper suggests removal of the unnecessary field initializer: