C# Fundamentals tutorial
Learn C# basics and build a strong foundation for .NET development.
Course contents
Getting Started
- 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.
- Data Types — Declare variables and constants, choose the right built-in type for a value, and convert between types with Convert, Parse and TryParse.
- Operators — Use arithmetic, comparison, logical, assignment and bitwise operators, and read an expression the way the compiler reads it.
Control Flow
- 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.
- 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.
- 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
- Arrays — Declare and initialize arrays, use Array class properties and methods, and work with single-dimensional, multidimensional and jagged arrays.
- Strings — Create and format strings, understand immutability, use String class methods, and build text efficiently with StringBuilder.
- 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
- Classes — Create classes and objects, store data in fields, expose it through properties, and use constructors to create valid objects.
- Static Classes — Create and use static fields, methods, properties, and constructors, and understand the difference between static and instance members.
- Advanced Classes — Split a class across multiple files with partial, create partial methods, and prevent inheritance with sealed.
- User Defined Data Types — Create structures and enumerations, understand value-type copying, and convert, parse, and combine enum values.
- Interfaces — Create and implement interfaces, implement multiple interfaces in one class, resolve name conflicts, and compare interfaces with abstract classes.
- Inheritance — Create derived classes, reuse members from base classes, recognise the inheritance models supported by C#, and pass values to base constructors.
- Polymorphism — Create overloaded methods and operators, override virtual methods, and understand the difference between override and new.
- Abstraction — Create abstract classes, methods, and properties, combine shared code with required behaviour, and hide implementation details.
- Encapsulation — Protect data with private fields, control access with access modifiers, validate values in properties, and create read-only members.
Generic Collections
- Generics — Write code that works with different types without rewriting it.
- List — Store items in order and add or remove them as needed.
- Dictionary — Store values using keys and find them quickly.
- Stack — Store items so the most recently added item comes out first.
- Queue — Store items so the earliest added item comes out first.
- HashSet — Store unique values and check quickly whether a value exists.
Exception Handling
- Exception Handling — Handle errors with try, catch, and finally, throw exceptions when needed, and preserve useful error information.
Delegates and Events
- Delegates — Store methods in variables, call them through delegates, attach multiple methods, and use Action, Func, and Predicate.
- Events — Create events, attach and remove handlers, pass information to subscribers, and raise events safely.
File Handling
- File Handling — Read and write files, work with folders and paths, process large files with streams, and close files safely with using.
Reference
- Cheat Sheet — Every topic in the course on one page: syntax, the members used most, and the mistakes that cost the most time.