Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Tag: yield return

C#

C#: Fix a yield return Iterator Delaying Its Own Argument-Validation Exception Until the First Call to MoveNext Instead of at Invocation

- 14.11.26 - ErcanOPAK comment on C#: Fix a yield return Iterator Delaying Its Own Argument-Validation Exception Until the First Call to MoveNext Instead of at Invocation

🔧 Fix a yield return Iterator Delaying Its Own Argument-Validation Exception Until the First Call to MoveNext Instead of at Invocation A method containing a yield return is compiled into a state machine, and none of the code inside that method’s body, including any argument validation written at the very top of it, actually runs […]

Read More
C#

C#: Fix a Yield Return Iterator That Never Runs Its Cleanup Code Because the Caller Abandoned the Enumerator Without Calling Dispose

- 30.10.26 - ErcanOPAK comment on C#: Fix a Yield Return Iterator That Never Runs Its Cleanup Code Because the Caller Abandoned the Enumerator Without Calling Dispose

🔧 Fix a Yield Return Iterator That Never Runs Its Cleanup Code Because the Caller Abandoned the Enumerator Without Calling Dispose A method using yield return compiles into a state machine implementing IEnumerator<T>, and any try/finally block written around the yield statements only runs its finally clause when that enumerator’s Dispose() method is called — […]

Read More
C#

C#: Why a Yield Return Iterator Doesn’t Run Any Code Until You Start Enumerating It

- 06.09.26 - ErcanOPAK comment on C#: Why a Yield Return Iterator Doesn’t Run Any Code Until You Start Enumerating It

🔧 Your Iterator Method’s Code Doesn’t Run Until Something Actually Enumerates It A method using `yield return` is called, and none of the code inside it appears to execute at all – not even a `Console.WriteLine` on the very first line – which confuses people expecting a method call to run its body immediately, because […]

Read More
C#

C#: Use IAsyncEnumerable for Streaming Large Data Sets

- 15.02.26 - ErcanOPAK comment on C#: Use IAsyncEnumerable for Streaming Large Data Sets

Loading all results into memory first is wasteful. IAsyncEnumerable streams results as they’re retrieved. Old Way – Load Everything: public async Task GetOrdersAsync() { return await _db.Orders.ToListAsync(); // Loads all 1 million orders into memory! } // Caller: var orders = await GetOrdersAsync(); // 5GB in memory foreach (var order in orders) ProcessOrder(order); Stream with […]

Read More
November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (653)
  • Add Constraint to SQL Table to ensure email contains @ (609)
  • Average of all values in a column that are not zero in SQL (570)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (547)
  • Find numbers with more than two decimal places in SQL (475)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com