Compiler error · error CS0103

The name 'X' does not exist in the current context

You used a name — a variable, a method, a class — that the compiler cannot see from where you used it. Three causes cover almost every case: a typo, wrong scope, or a member that isn't declared.

Cause 1: a typo (the most common)

The variable is score, you typed scroe. C# is case-sensitive, so Score ≠ score:

int score = 100;
Console.WriteLine(scroe);   // typo: declared 'score', used 'scroe'
int score = 100;
Console.WriteLine(score);   // exact match — case included

Cause 2: used before it exists

A variable exists from its declaration downward. Using it one line above the declaration fails:

Console.WriteLine(total);   // 'total' is declared *below* this line
int total = 42;
int total = 42;             // declare first…
Console.WriteLine(total);   // …use after

Cause 3: outside its scope — the braces trap

A variable declared inside a block { … } dies at the closing brace. This is the one that surprises people coming from Python or JavaScript's older var:

for (int i = 0; i < 3; i++)
{
    int doubled = i * 2;
}
Console.WriteLine(doubled);   // 'doubled' lived only inside the loop body

Fix: declare it outside the block, at the level where you need it:

int last = 0;
for (int i = 0; i < 3; i++)
{
    last = i * 2;             // assign inside…
}
Console.WriteLine(last);      // …read outside (last one was 2*2)

Frequently asked

How do I fix error CS0103 in C#?

A variable declared inside a block dies at the closing brace. Declare it outside the loop (int last = 0;) and assign inside if you need the value after the loop ends.

Why do I get CS0103 for a variable I declared inside a loop?

undefined

Cause 4: a class member you never declared

Calling a method that doesn't exist — or forgetting the parentheses on one that does — produces the same code:

PrintReport();   // no such method exists anywhere
void PrintReport()
{
    Console.WriteLine("Report: all good");
}

PrintReport();   // now the name exists

How to debug it fast