Fork me on GitHub
TypeName MakeLocalVariableConstWhenItIsPossibleAnalyzer
Check Id CC0030
Category Performance
Severity Info

Cause

This variable is assigned a constant value and never changed, it can be made a const

Example

class Class1
{
    int Foo()
    {
        int a = 10;

        return a;
    }
}

Code fix

A code fix will be presented to you that will transform the code:

class Class1
{
    int Foo()
    {
        const int a = 10;

        return a;
    }
}

Code fix

Related rules

None

See also

TBD