C# Syntax Overview

C# is a modern, object-oriented programming language developed by Microsoft. (We're not gonna talk about what "object-oriented" means right now - we'll touch on it here and there during the course.) Its syntax is derived from C and C++, but it includes many improvements and features that make it more robust and developer-friendly. Here's an overview of C#'s key syntactic elements:

Basic Structure

  • C# uses curly braces {} to define code blocks. For example:

    if (condition)
    {
        // code block
    }
    
  • Statements end with semicolons ;.

  • The language is not whitespace-sensitive, but proper indentation is recommended for readability. Let's not get started on tabs vs spaces though, just be consistent :)

Comments

Comments are blocks of text that will not be interpreted as code.

  • Single-line comments start with //. For example:

    // This is a single-line comment
    
  • Multi-line comments are enclosed in /* */. For example:

    /* This is a 
       multi-line 
       comment */
    

Common Syntax Errors

  1. Missing semicolon at the end of a statement.
  2. Mismatched curly braces.
  3. Using = instead of == for comparison in conditions.
  4. Forgetting to declare variables before use.
  5. Incorrect casing (C# is case-sensitive).

Remember, while C# is not whitespace-sensitive, consistent indentation greatly improves code readability and helps prevent errors.