C# Fundamentals tutorial

Learn C# basics and build a strong foundation for .NET development.

Start the course

Course contents

Getting Started

  1. Introduction to C# — Run your first C# program, learn where a program starts, print text to the console, read what the user types with Console.ReadLine, and use escape sequences for tabs, quotation marks and backslashes.
  2. Data Types — Declare variables and constants, choose the right built-in type for a value, and convert between types with Convert, Parse and TryParse.
  3. Operators — Use arithmetic, comparison, logical, assignment and bitwise operators, and read an expression the way the compiler reads it.

Control Flow

  1. Conditional Statements — Make decisions with if, if-else and else-if, build conditions from comparison and logical operators, and return values with the conditional operator and switch.
  2. Loops — Repeat work with for, while, do-while and foreach, control loops with break and continue, and avoid infinite loops and off-by-one errors.
  3. Methods — Declare and call methods, pass data with value, ref, out, in and params parameters, return values, and write optional, recursive, overloaded and anonymous methods.

Reference Types

  1. Arrays — Declare and initialize arrays, use Array class properties and methods, and work with single-dimensional, multidimensional and jagged arrays.
  2. Strings — Create and format strings, understand immutability, use String class methods, and build text efficiently with StringBuilder.
  3. DateTime — Create and format DateTime values, parse dates from text, perform date arithmetic and comparison, and use TimeSpan, DateOnly, TimeOnly and time zones.

Object-Oriented Programming

  1. Classes — Create classes and objects, store data in fields, expose it through properties, and use constructors to create valid objects.
  2. Static Classes — Create and use static fields, methods, properties, and constructors, and understand the difference between static and instance members.
  3. Advanced Classes — Split a class across multiple files with partial, create partial methods, and prevent inheritance with sealed.
  4. User Defined Data Types — Create structures and enumerations, understand value-type copying, and convert, parse, and combine enum values.
  5. Interfaces — Create and implement interfaces, implement multiple interfaces in one class, resolve name conflicts, and compare interfaces with abstract classes.
  6. Inheritance — Create derived classes, reuse members from base classes, recognise the inheritance models supported by C#, and pass values to base constructors.
  7. Polymorphism — Create overloaded methods and operators, override virtual methods, and understand the difference between override and new.
  8. Abstraction — Create abstract classes, methods, and properties, combine shared code with required behaviour, and hide implementation details.
  9. Encapsulation — Protect data with private fields, control access with access modifiers, validate values in properties, and create read-only members.

Generic Collections

  1. Generics — Write code that works with different types without rewriting it.
  2. List — Store items in order and add or remove them as needed.
  3. Dictionary — Store values using keys and find them quickly.
  4. Stack — Store items so the most recently added item comes out first.
  5. Queue — Store items so the earliest added item comes out first.
  6. HashSet — Store unique values and check quickly whether a value exists.

Exception Handling

  1. Exception Handling — Handle errors with try, catch, and finally, throw exceptions when needed, and preserve useful error information.

Delegates and Events

  1. Delegates — Store methods in variables, call them through delegates, attach multiple methods, and use Action, Func, and Predicate.
  2. Events — Create events, attach and remove handlers, pass information to subscribers, and raise events safely.

File Handling

  1. File Handling — Read and write files, work with folders and paths, process large files with streams, and close files safely with using.

Reference

  1. Cheat Sheet — Every topic in the course on one page: syntax, the members used most, and the mistakes that cost the most time.