Code inspection: Convert local variable or field into constant (private accessibility)
This inspection reports a local variable or non-public field with a compile-time constant initializer that can be declared as const.
For local variables, this usually means the value is assigned once and never changes. Declaring it as const makes that intent explicit.
Example
public class Example
{
public int GetBufferSize()
{
int size = 256;
return size;
}
}
public class Example
{
public int GetBufferSize()
{
const int size = 256;
return size;
}
}
Quick-fix
The quick-fix converts the declaration to const.
27 March 2026