C# error decoder
Search brings you here with a code like error CS0029 and a deadline. Each page below makes the error happen live in your browser, explains the cause in plain English, and hands you the fix to copy.
Syntax errors
-
CS1002— ; expectedThe most common C# error. The real mistake is on the line before the one the error points at — plus what does and doesn't need a semicolon. -
CS1513— } expectedA block was never closed. The error line is where the compiler gave up, not where the brace belongs — brace-counting ritual included. -
CS1525— Invalid expression term 'X'A value slot holding punctuation: an empty initializer, a dangling operator, empty parens. Five shapes plus the cascade check. -
CS1022— Type or namespace definition, or end-of-file expectedOne closing brace too many — the mirror of CS1513. Brace counting finds it in seconds. -
CS1519— Invalid token in class, struct, or interface member declarationA statement where a member should be, or a field with no type. Why executable code must live in a method. -
CS1001— Identifier expectedA name slot got a value, or a keyword was used as a name. The five name slots and the@escape. -
CS1031— Type expectednew 5(), empty generics, parameters with no type — the type-shaped sibling of CS1001.
Type conversion errors
-
CS0029— Cannot implicitly convert type 'X' to 'Y'You put a string where a number belongs (or vice versa). Four causes, four fixes, plus the difference from CS0266. -
CS0019— Operator cannot be applied to operands of type 'X' and 'Y'The operator has no version for those two types: subtracting from a string, comparing int with string, adding to a bool. -
CS0021— Cannot apply indexing with [] to an expression of type 'X'Square brackets on something that holds one value, not many. What is actually indexable in C#, and the number→digit patterns. -
CS1955— Non-invocable member 'X' cannot be used like a methodParentheses on a property:list.Count()should belist.Count. The action-vs-value rule that decides it.
Name resolution errors
-
CS0103— The name 'X' does not exist in the current contextTypo, use-before-declaration, or the braces-scope trap. The three causes cover almost every occurrence. -
CS0246— The type or namespace name 'X' could not be foundUnknown type (not variable): misspelled class, missing using, or an unreferenced package. Decision table included. -
CS1061— 'X' does not contain a definition for 'Y'The variable is fine; the part after the dot isn't. Typos, wrong casing, the wrong type's member, and calling a property like a method. -
CS0117— 'X' does not contain a definition for 'Y' (static members)The type-level twin of CS1061: a typo after the class name, likeConsole.WritLineorMath.Sqr.
Flow-control errors
-
CS0165— Use of unassigned local variable 'x'Read before written — C# refuses to hand you a silent zero. Why assignment inside oneifbranch isn't enough, and the three fixes. -
CS0163— Control cannot fall through from one case label to anotherC# refusing the C-era switch bug. Every case ends in break/return/throw — and how stacked labels give you the "fall-through" you actually wanted. -
CS0161— Not all code paths return a valueA non-void method with a branch that falls off the end. The if/else, trailing-return and switch-default fixes. -
CS1503— Argument N: cannot convert from 'X' to 'Y'The method-argument sibling of CS0029. Convert at the call site, or fix the signature. -
CS0122— 'X' is inaccessible due to its protection levelYou reached for a private member from outside. The property/method fixes — and why not to just make everything public.
Declarations & assignment
-
CS0128— A local variable named 'X' is already definedDeclared the same name twice in one scope — usually a copy-paste leftover carrying its type keyword. Assign vs re-declare, and why different scopes may share names. -
CS0131— The left-hand side of an assignment must be a variableNowhere to store: a constant, a literal, or an expression sat left of '='. What the left side is allowed to be.
Method & constructor calls
-
CS1501 / CS7036— wrong number of method argumentsYour call and the parameter list disagree on count. Optional parameters, overloads, and named arguments as the rescue. -
CS1729— 'X' does not contain a constructor that takes N argumentsDeclaring any constructor removes the free empty one — whynew X()suddenly breaks, and the two fixes.
Coverage
That's 24 of the most common beginner-facing compiler errors, each with a live repro. Ran into one that's not here? Tell us and it moves to the front of the queue.