Back to Browse

Stop Returning Lists — Use Yield in C#

702 views
Mar 8, 2024
11:59

Learn how to make your C# code faster and more memory‑efficient by using yield return, yield break, IEnumerable, and IAsyncEnumerable. Instead of building full lists in memory, yield lets you stream data one item at a time. In this video, Chuck shows how yield works behind the scenes, how enumerator state machines operate, and when async iteration makes your code even cleaner. What You’ll Learn - Why yield return is faster than building lists - How C# enumerators and state machines work - Using yield break - Streaming data from files - Async iteration with await foreach - Writing your own enumerable class - When not to use yield Chapters 00:00 Introduction 00:25 IEnumerable 01:56 Yield Return 02:54 Understanding yield return 04:45 Enumerator State 05:38 Yielding from a file 06:43 Advantages of yield 07:53 Yield Break 08:15 Limitations 08:43 Async Yield 09:38 IEnumerable Class 10:17 Conclusions Resources Website: https://www.McCulloughAssociates.com C# yield, yield return, yield break, C# IEnumerable, C# IAsyncEnumerable, C# async streams, iterator pattern, C# performance tips, .NET tutorial, C# coding best practices, C# beginner tutorial, C# advanced concepts

Download

0 formats

No download links available.

Stop Returning Lists — Use Yield in C# | NatokHD