Free course · 11 lessons · Beginner
C# Fundamentals: From Your First Program to Async and JSON
Learn modern C# on .NET from the first line to real applications: the dotnet CLI, types and string formatting, control flow and methods, collections and LINQ, classes, records and structs, interfaces and polymorphism, null safety and pattern matching, generics, delegates and events, async/await, exceptions and IDisposable, files, JSON and dates, and an inventory-processor capstone. Every example is compiled with the .NET SDK and shown with its real output.
1. C# Basics: Types, Collections, Classes and Pattern Matching
Write modern C# from the first line: the dotnet CLI, types and strings, control flow and methods, collections with LINQ, classes and records, interfaces, and null safety with pattern matching.
- Hello, C#: The dotnet CLI, Types and Strings — Create and run a C# project with the dotnet CLI, use top-level statements, declare typed variables, build strings with interpolation and format specifiers, and understand value versus reference types.
- Control Flow, Methods and Tuples — Branch with if and switch expressions, loop with for, foreach and while, write methods with optional and named arguments, and return several values with tuples.
- Collections and LINQ — Use List, Dictionary and HashSet, and query data declaratively with LINQ: Where, Select, OrderBy, GroupBy, Join and aggregation.
- Classes, Records and Structs — Model data with classes, properties and constructors, use records for immutable values with value equality, and know when a struct is the right choice.
- Interfaces, Inheritance and Polymorphism — Define contracts with interfaces, share behavior with abstract base classes, override members, and prefer composition and dependency injection over deep inheritance.
- Null Safety and Pattern Matching — Use nullable reference types, the ?. ?? and ??= operators, and C# patterns (type, property, relational, list) to write code that handles every case.
2. Modern C# in Practice: Generics, Async, Errors and JSON
The tools you use in real .NET applications: generics, delegates and events, async/await, exceptions and resource cleanup, JSON and files, and a complete inventory processor.
- Generics, Delegates, Lambdas and Events — Write reusable generic types with constraints, pass behavior as Func and Action delegates, use lambdas, and publish events that other code can subscribe to.
- async/await and Tasks — Write asynchronous code that doesn't block threads, run operations concurrently with Task.WhenAll, support cancellation and timeouts, and avoid the classic async pitfalls.
- Exceptions and Resource Cleanup with IDisposable — Throw and catch exceptions properly, create custom exception types, use filters and finally, and release resources deterministically with IDisposable and using.
- Files, JSON and Dates — Read and write files, serialize objects to and from JSON with System.Text.Json, control naming and indentation, and handle dates without time-zone surprises.
- Capstone: An Inventory Processor — Combine records, LINQ, pattern matching, async loading and JSON in one program that loads stock data, validates it, summarizes it and writes a report.