Stage 2 · Lesson 4 of 6
Generics, delegates and lambdas
let you write code once for many types while staying type-safe: List<T>, Task<T>, ILogger<T> and IRepository<T> are all generic. Constraints such as where T : class limit which types fit. Delegates are typed references to methods, and lambdas such as o => o.Total > 1000 are short inline functions.
Func<T, TResult> and Action<T> are the delegate types you will see everywhere: every method takes one, and so does every builder.Services.AddX(options => ...) call in Program.cs. , a static method with a this parameter, are how LINQ and those AddX calls attach to existing types.
You do not need to write clever generic libraries, but you must read generic signatures comfortably.
Common trapa generic repository wrapped around EF Core that hides and loads too much.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Data Structures & Algorithms for Coding Interviews
Design Gurus · Beginner · Subscription
Arrays, hash tables, lists, stacks and queues: what every C# collection is built on, with complexity explained
- GuideFree.NET documentation
Microsoft
Free official guides on LINQ, generics, collections and the asynchronous programming model