Total .NET Analyzer Rule Documentation  

TightenFieldScope Rule

Make the scope of the field as tight as possible.

Remarks

When declaring a variable, you should make the scope as tight as possible to conserve memory and minimize runtime errors. For example, do not declare a variable at the class level if it is only used in one procedure.

Tight variable reduces memory usage, improves performance, and makes it more difficult to introduce bugs by referring to a type in the wrong place.

By default, Total .NET Analyzer does not identify constants and controls that can be tightened. You can change this default behavior through the Rule Editor.

Resolution

Examine the code to determine where the field is used, and move the definition so that it is available only to the members that use it.

See Also

VB Choice of Variable Scope

C# Scopes