scitools.com

← Metric catalog

Internal Instance Variables is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.

Internal Instance Variables

API ID: CountDeclInstanceVariableInternal
Languages: C#
Targets: Architectures, Classes, Project

Number of internal instance variables.

An internal instance variable (C#'s internal access modifier) is accessible from anywhere in the same assembly, but not from other assemblies.

For example:


namespace MetricsDemo
{
    public class AccessModifiers
    {
        internal int InternalField;
        protected internal int ProtectedInternalField;

        internal void InternalMethod()
        {
            InternalField++;
        }

        protected internal void ProtectedInternalMethod()
        {
            ProtectedInternalField++;
        }
    }
}

InternalField is the only internal instance variable, giving CountDeclInstanceVariableInternal = 1. ProtectedInternalField is protected internal — a different, broader access level (accessible from the same assembly OR from derived classes in other assemblies) — so it doesn't count here.

See Instance Variables for the total across all access levels, and Protected Internal Instance Variables for the related access level. Public Instance Variables, Protected Instance Variables, and Private Instance Variables cover the access levels shared with C++ and Java.

Targets By Language: Configuration: