Compiler error ยท error CS1525

Invalid expression term 'X'

The compiler was reading an expression โ€” a place where a value must appear โ€” and hit punctuation instead. Something that should hold a value is empty.

See it happen

int x = ;   // the right-hand side of = must be a value

Shape 1: an empty initializer

string name = ;
string name = "(unnamed)";
Console.WriteLine(name);

Shape 2: a dangling operator

An operator with nothing to operate on is the same problem โ€” it needs an operand:

int total = 10 + ;   // + needs a right-hand value
int total = 10 + 5;
Console.WriteLine(total);

Shape 3: empty parentheses

bool ready = true;
if ()
{
    Console.WriteLine("go");
}
bool ready = true;
if (ready)              // if needs a bool expression between the parens
{
    Console.WriteLine("go");
}

Shape 4: a missing comma or operator between values

int a = 5;
int b = a * * 3;   // two operators in a row โ€” the compiler expects a value between them
int a = 5;
int b = a * 3;   // one operator, one value on each side
Console.WriteLine(b);

Shape 5: a cascade from an unclosed bracket

If nothing on the reported line looks wrong, look at the line above โ€” an unclosed ( or [ makes the compiler keep reading into your next line and trip somewhere odd. The real fix is often one character earlier.

Frequently asked

What does CS1525 mean?

The compiler expected a value and found punctuation or nothing. Supply the missing expression, remove the stray operator, or complete the argument.

Could it be a cascade?

Yes โ€” an unclosed parenthesis or bracket on the previous line produces this further down. Check the token before the reported position first.

Checklist