Difference between revisions of "Syntax Error"

esse quam videri
Jump to: navigation, search
(Created page with " =Definition= =Relevance= =Explanation= =Resources= == See also == ==Notes== ==External Links== Category:Programming Language Concepts Category:Object Orient...")
 
(Notes)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
 
=Definition=
 
=Definition=
 +
A syntax error is a type of error that will prevent the code from compiling at compile time.
  
 
=Relevance=
 
=Relevance=
 +
Syntax errors will be a common sight. The most famous is forgetting to add a semicolon at the end of a line of code. Most of the time, syntax errors are quick to resolve.
  
 
=Explanation=
 
=Explanation=
 +
Because syntax errors prevent the code from compiling, compiled programming languages (such as C#) will not allow the user from running the code until the error is resolved.
  
 +
=Example=
 +
<syntaxhighlight lang ="csharp">
 +
string name = "John Doe";
  
 
+
Console.WriteLine(Name); // This is a syntax error because we are trying to print "name" but this line of code says "Name". Although it seems insignificant, this code will not compile because there is no variable with the identifier "Name".
=Resources=
+
</syntaxhighlight>
== See also ==
 
 
 
  
 
==Notes==
 
==Notes==
 +
In Microsoft Visual Studio, syntax errors are typically underlined in a red squigly line to try to help identify them.
  
 +
Syntax errors are kind of like grammatical errors in writing, and solving them requires a similar strategy to fixing grammatical errors.
  
==External Links==
+
==See Also==
 
+
[[Logic Error]]
  
  

Latest revision as of 16:36, 15 April 2020

Definition

A syntax error is a type of error that will prevent the code from compiling at compile time.

Relevance

Syntax errors will be a common sight. The most famous is forgetting to add a semicolon at the end of a line of code. Most of the time, syntax errors are quick to resolve.

Explanation

Because syntax errors prevent the code from compiling, compiled programming languages (such as C#) will not allow the user from running the code until the error is resolved.

Example

string name = "John Doe"; 

Console.WriteLine(Name); // This is a syntax error because we are trying to print "name" but this line of code says "Name". Although it seems insignificant, this code will not compile because there is no variable with the identifier "Name".

Notes

In Microsoft Visual Studio, syntax errors are typically underlined in a red squigly line to try to help identify them.

Syntax errors are kind of like grammatical errors in writing, and solving them requires a similar strategy to fixing grammatical errors.

See Also

Logic Error