Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 645 Bytes

RCS1171.md

File metadata and controls

39 lines (28 loc) · 645 Bytes

RCS1171: Simplify lazy initialization

Property Value
Id RCS1171
Category Simplification
Severity Info

Example

Code with Diagnostic

public object Foo()
{
    if (_foo == null) // RCS1171
    {
        _foo = Initialize();
    }

    return _foo;
}

Code with Fix

public object Foo()
{
    return _foo ?? (_foo = Initialize());
}

See Also

(Generated with DotMarkdown)