Excellent. Here’s **PHASE 4 – GENIUS LEVEL (Lessons 13–15)** of your **C# Masterclass**. These lessons push into advanced C# features: async programming, reflection, generics, and the final capstone integration project. --- # 🧠 C# MASTERCLASS — PHASE 4 GENIUS LEVEL **Goal:** Master performance, parallelism, and dynamic capabilities, culminating in a real-world application. --- ## Lesson 13 – Asynchronous Programming and Threading ### Objectives - Understand concurrency vs. parallelism - Use `async` / `await` with `Task` - Handle multiple concurrent operations ### Asynchronous Example ```csharp using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { HttpClient client = new HttpClient(); string data = await client.GetStringAsync("https://api.github.com/zen", new HttpRequestMessage().Headers.Add("User-Agent", "CSharpMasterclass")); Console.WriteLine(data); } } ``` ### Parallel Example ```csharp using System.Threading.Tasks; Parallel.For(0, 5, i => { Console.WriteLine(quot;Task {i} running on thread {Task.CurrentId}"); }); ``` ### Task Coordination ```csharp async Task<int> SlowOp(int seconds) { await Task.Delay(seconds * 1000); return seconds; } var results = await Task.WhenAll(SlowOp(2), SlowOp(3), SlowOp(1)); Console.WriteLine(quot;Total time: {results.Max()} seconds"); ``` ### Mini-Project — Web Scraper - Accept list of URLs - Fetch HTML content concurrently - Save to local text files - Display completion time --- ## Lesson 14 – Reflection, Generics, and Advanced LINQ ### Objectives - Use reflection to inspect assemblies and types - Define and apply generics - Create dynamic data transformations ### Reflection Example ```csharp using System; using System.Reflection; Type t = typeof(System.String); Console.WriteLine(quot;Methods in {t.Name}:"); foreach (var m in t.GetMethods().Take(5)) Console.WriteLine(m.Name); ``` ### Generics Example ```csharp class Box<T> { public T Value { get; set; } public Box(T value) => Value = value; } var intBox = new Box<int>(10); var strBox = new Box<string>("Hello"); Console.WriteLine(intBox.Value + " " + strBox.Value); ``` ### Dynamic LINQ Example ```csharp var data = new[] { 1, 2, 3, 4, 5 }; var query = data.Where(x => x % 2 == 0).Select(x => x * x); foreach (var q in query) Console.WriteLine(q); ``` ### Mini-Project — Simple IoC Container - Create a container that registers interfaces and implementations. - Use reflection to instantiate requested types. - Demonstrate dependency resolution similar to DI frameworks. --- ## Lesson 15 – The Capstone Project ### Objective Combine all knowledge into a final project of your choice. ### Project Options #### 🖥️ Option 1 – Desktop Utility: _BlueZone Companion_ A Windows desktop tool that automates repetitive file or terminal tasks. **Key Elements** - File I/O from Phase 3 - Async operations for background work - Logging with `StreamWriter` - Modular classes and interfaces #### 🌐 Option 2 – Web App: _Lucky Griffon Dashboard_ A full ASP.NET Core MVC or Razor Pages web app. **Key Elements** - EF Core for persistence - Async API calls for dashboard widgets - Clean architecture using DI #### 🕹️ Option 3 – Game: _Sordia Vignti Tactics_ A simple tactical engine built with Unity using C# scripts. **Key Elements** - Classes for entities (Player, Enemy) - Polymorphism for abilities - Async loading and coroutines #### ⚙️ Option 4 – Automation: _Payroll Deduction Bot_ A C# console app that automates Excel interaction using Interop. **Key Elements** - File processing - Loops and collections - Exception handling and logging ### Structure for All Capstones 1. **Plan:** Define goal and features 2. **Design:** Outline classes and data flow 3. **Build:** Implement iteratively 4. **Test:** Add unit tests (xUnit or NUnit) 5. **Deploy:** Package for use --- ### ✅ End of Phase 4 Summary You now command: - Asynchronous and parallel programming - Reflection and generics - Architectural integration Next comes **Phase 5 – Developer’s Mind (Lessons 16–19)** — covering version control, testing, optimisation, and deployment. Would you like me to continue and generate **Phase 5 now**?