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: Redundant member initializer

Last modified: 11 February 2024

Fields in types get initialized to their default value. This means that declaring a field like so

is meaningless because _name would be initialized to null anyway. Thus, you can safely remove the initialization.

The above applies not only to reference types (which get defaulted to null), but also value types. For example, integer types are assigned to 0 (zero).