Lesson 1 — Getting Started

Introduction to C#

C# is Microsoft's flagship language — modern, type-safe, and the backbone of Azure cloud, ASP.NET APIs, Unity games, and enterprise software across South Africa.

CSHARP — Classic Hello.cs
using System;

class Hello {
    static void Main(string[] args) {
        Console.WriteLine("Sawubona, world!");
    }
}

What is C#?

C# (C-sharp) was designed by Anders Hejlsberg at Microsoft, first released in 2000. It is a statically typed, object-oriented language that runs on the .NET runtime (CLR). Like Java, it compiles to intermediate language (IL) that the CLR executes — giving it portability across Windows, Linux, and macOS. Unlike Java, C# has properties, LINQ, async/await, nullable reference types, and records built into the language.

Why C# Matters in South Africa

Microsoft's technology stack — Azure cloud, SQL Server, ASP.NET, SharePoint, Office 365 — is embedded in South African banking, insurance, retail, and government. Absa, Discovery, Standard Bank, and many government departments run on .NET infrastructure. Unity, the dominant game engine, uses C# as its scripting language. Knowing C# opens paths to enterprise backend development, cloud engineering, and game development.

Modern Top-Level Statements

C# 9+ supports top-level statements — for simple programs you can skip the class and Main boilerplate:

CSHARP — Top-level + interpolation
// No class or Main needed in C# 9+
Console.WriteLine("Sawubona, world!");
Console.WriteLine("Welcome to Your IT Tutor C# training.");

// String interpolation — prefix with $ and embed {expressions}
string name = "Thandi";
int age = 21;
Console.WriteLine($"Hello, {name}. You are {age} years old.");
Console.WriteLine($"In 5 years: {age + 5}");

C# vs Java — Key Differences to Know

  • Method names — PascalCase in C# (GetLength) vs camelCase in Java (getLength).
  • Properties — C# has built-in property syntax instead of explicit getters/setters.
  • var — compile-time type inference. C# has had it since 2008.
  • decimal type — C# has a base-10 decimal type for financial precision (Java relies on BigDecimal).
  • LINQ — Language Integrated Query for collections, databases, and XML — no Java equivalent in the language itself.

Practice Task

Your Turn

Write a program storing your name, city, course, and birth year. Use string interpolation to print: a greeting, your calculated age (use DateTime.Now.Year - birthYear), your city, and what you want to build after Your IT Tutor training.

Common Mistakes

  • Forgetting using System; when not using top-level statements — Console is in the System namespace.
  • Forgetting the $ prefix on an interpolated string — {name} prints literally.
  • camelCase method names — in C#, methods are PascalCase: WriteLine not writeLine.
  • Installing Visual Studio without the .NET SDK workload — you need the SDK to compile.

Professional Tip

C# and Java are close cousins — if you know one, you can read the other immediately. The differences (properties, LINQ, delegates) emerge over the next lessons and represent genuine improvements in developer ergonomics.

Mini Quiz

What prefix makes a C# string an interpolated string?