How to distinguish between local and static variables of the same name

Example

to illustrate:

public class Something
{
    private static int number;

    static Something()
    {
        int number = 10;

        // Syntax to distingish between local variable and static variable ?
    }
}

Is there a syntax inside the static constructor that can be used to distinguish between a local variable named "number" and a static variable with the same name?

+5
source share
2 answers
Something.number

Obviously not?

+8
source

Unqualified will get you an internal variable with scope (local variable):

Console.WriteLine(number);

10

You can qualify your use to get a static variable:

Console.WriteLine(Something.number);

0

+3
source

All Articles