INTRODUCTION TO PROGRAMMING & BASIC SYNTAX IN C#

3. Basic C# Syntax and Fundamentals

C# Syntax Rules

  • Case Sensitivity: C# is case-sensitive (myVariable ≠ MyVariable)
  • Semicolons: Every statement must end with a semicolon (;)
  • Code Blocks: Use curly braces {} to group statements
  • Whitespace: Spaces and tabs are generally ignored (except in strings)

Comments in C#
Comments are non-executable text for documentation:

Single-line Comments:

// This is a single-line comment

Console.WriteLine("Hello"); // Comment after code

Multi-line Comments:

/* This is a multi-line comment

   that spans across multiple

   lines of text */