Reading and fixing a compiler error
A compiler error is a precise message, not a punishment. It tells you the file, the line and the thing it did not understand.
Read it in three parts
- The file and line. Click the error to jump there.
- The complaint. For example, a missing semicolon, an unknown name or a type mismatch.
- The context. Sometimes the real mistake is on the line above the one named.
The errors you will meet first
- A name that does not exist in the current context: usually a spelling mistake or a missing using statement.
- A semicolon expected: a missing punctuation mark on the previous line.
- Cannot convert type: you are putting the wrong kind of value into a variable.
Fix the first error only. Then rebuild. The list usually shrinks on its own because later errors were consequences of the first.
When the build succeeds but the page still misbehaves, switch from the compiler to the debugger. If you want fewer errors in the first place, commenting your code helps you reason about it.