<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[.NET Fiddle - Medium]]></title>
        <description><![CDATA[Code, compile, and collaborate. We explore the power of .NET Fiddle for rapid prototyping, sharing C# snippets, and mastering the .NET ecosystem — one browser tab at a time. No local setup required. - Medium]]></description>
        <link>https://medium.com/net-fiddle?source=rss----4ab188f43763---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>.NET Fiddle - Medium</title>
            <link>https://medium.com/net-fiddle?source=rss----4ab188f43763---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:17:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/net-fiddle" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Switch Statement Finally Went on a Diet]]></title>
            <link>https://medium.com/net-fiddle/the-switch-statement-finally-went-on-a-diet-c7e2831410e7?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/c7e2831410e7</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 09:07:47 GMT</pubDate>
            <atom:updated>2026-09-21T09:07:47.673Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4hwHw_XEJKIIIN6I8ZqNw.jpeg" /></figure><p>Ten lines of switch statement, one line of judgment. That’s basically what the <strong>switch expression</strong> is: C# finally admitting braces and break; were dead weight.</p><p>A switch expression evaluates directly to a value, no case, no break, no fallthrough bugs waiting to ruin your Friday deploy. It landed in C# 8 back in 2019, quietly making pattern matching feel less like Java cosplay.</p><pre>string newMood = coffeeCount switch // &lt;&lt;&lt; replaces the entire switch statement above with one expression<br>{<br>0 =&gt; &quot;Dead&quot;,<br>1 =&gt; &quot;Tired&quot;,<br>_ =&gt; &quot;Wired&quot;<br>};</pre><p>Compare that to the switch statement doing the exact same job in eight extra lines. Microsoft spent two decades adding braces before finally admitting less is more.</p><p><strong><em>Try it yourself (no setup required):</em></strong> <a href="https://dotnetfiddle.net/ONdQIE?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=switch-expressions-vs-switch-statements-in-c-">https://dotnetfiddle.net/ONdQIE</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7e2831410e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/the-switch-statement-finally-went-on-a-diet-c7e2831410e7">The Switch Statement Finally Went on a Diet</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LanguageExt: Functional C# That Doesn’t Trust Null]]></title>
            <link>https://medium.com/net-fiddle/languageext-functional-c-that-doesnt-trust-null-cc3fef6cd7d6?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/cc3fef6cd7d6</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 13:48:00 GMT</pubDate>
            <atom:updated>2026-09-18T13:48:00.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lqyAr9TC-iNKpN2aAAOfaQ.jpeg" /></figure><p>Null reference exceptions have haunted C# since day one, and Microsoft still hasn’t really fixed it.</p><p><strong>LanguageExt</strong> brings actual functional programming to C#: Option&lt;T&gt; instead of null, Either&lt;L,R&gt; for real error handling, immutable collections, and pattern matching that actually matches patterns.</p><p>Paul Louth started the project back in 2014, basically importing F#’s best ideas into C# because waiting for Microsoft felt like waiting for Godot.</p><p>Here’s Option&lt;T&gt; replacing the classic ‘might return null, good luck’ method:</p><pre>Option&lt;string&gt; FindCoffeeOrder(int id) =&gt;<br>id == 42 ? Some(&quot;Triple Espresso, extra shot of hope&quot;) : None; // &lt;&lt;&lt; returns Some or None, never null<br>var order = FindCoffeeOrder(42);<br>order.Match(<br>Some: o =&gt; Console.WriteLine($&quot;Found: {o}&quot;),<br>None: () =&gt; Console.WriteLine(&quot;No order found&quot;)<br>);</pre><p>No null. No exception. Just a clean Some or None, and your coffee order survives the day.</p><p><strong><em>Try it yourself (no setup required):</em></strong> <a href="https://dotnetfiddle.net/y1qRJ0?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=languageext-option-t-no-more-null-coffee-orders">https://dotnetfiddle.net/y1qRJ0</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc3fef6cd7d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/languageext-functional-c-that-doesnt-trust-null-cc3fef6cd7d6">LanguageExt: Functional C# That Doesn’t Trust Null</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AutoMapper: Because Nobody Wants to Write dto.Name = customer.Name Forever]]></title>
            <link>https://medium.com/net-fiddle/automapper-because-nobody-wants-to-write-dto-name-customer-name-forever-897b62bea60c?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/897b62bea60c</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 08:59:20 GMT</pubDate>
            <atom:updated>2026-09-16T08:59:20.329Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wx67MMjdh8KkPp_nc27oBA.png" /></figure><p>Ever copy-paste the same property assignments between a DTO and a domain object, then do it again in the next class? Yeah, that used to be me.</p><p><strong>AutoMapper</strong> is a convention-based object mapper. Define the mapping once and it matches properties by name, so you stop writing manual assignment code every time the DTO layer changes.</p><pre>var config = new MapperConfiguration(cfg =&gt; cfg.CreateMap&lt;CustomerDto, Customer&gt;()); // &lt;&lt;&lt; defines the mapping rule once<br>var mapper = config.CreateMapper();<br>var dto = new CustomerDto { Name = &quot;Marty McFly&quot;, Email = &quot;marty@bttf.com&quot; };<br>var customer = mapper.Map&lt;Customer&gt;(dto);<br>Console.WriteLine($&quot;{customer.Name} | {customer.Email} | Created {customer.CreatedAt.Year}&quot;);</pre><p>Jimmy Bogard shipped it back in 2009 to kill repetitive mapping code in layered apps, and it’s been the default choice for DTO-to-entity mapping in .NET ever since.</p><p>Microsoft still hasn’t shipped a built-in mapper after all these years, so AutoMapper keeps its job security.</p><p><strong><em>Try it yourself (no setup required):</em></strong> <a href="https://dotnetfiddle.net/guAwxS?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=automapper-dto-to-domain-object-mapping-in-one-lin">https://dotnetfiddle.net/guAwxS</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=897b62bea60c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/automapper-because-nobody-wants-to-write-dto-name-customer-name-forever-897b62bea60c">AutoMapper: Because Nobody Wants to Write dto.Name = customer.Name Forever</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Records Have Family Drama Too: Open vs Sealed Inheritance]]></title>
            <link>https://medium.com/net-fiddle/records-have-family-drama-too-open-vs-sealed-inheritance-b52467f6777d?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/b52467f6777d</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 17:21:30 GMT</pubDate>
            <atom:updated>2026-09-14T17:21:30.591Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sc6eZwkKTtDiztR_49iMWg.png" /></figure><p>Records can inherit from other records — and most devs never touch that button. Turns out <strong>record inheritance</strong> gets weird fast, especially around equality.</p><p>A record’s Equals doesn’t just compare properties — it also checks the runtime type. So a base-typed reference holding a Dog and one holding a Puppy will never be equal, even with identical values, because they’re different types under the hood. Keep the hierarchy open and you can keep deriving forever. Seal a record and that branch is locked — no more subclassing, period.</p><pre>Animal animal = new Dog(&quot;Rex&quot;, &quot;Labrador&quot;);<br>Animal sameDog = new Dog(&quot;Rex&quot;, &quot;Labrador&quot;);<br>Console.WriteLine(animal == sameDog); // &lt;&lt;&lt; true: same runtime type and values<br>Animal puppy = new Puppy(&quot;Rex&quot;, &quot;Labrador&quot;, 3);<br>Console.WriteLine(animal == puppy); // false: different runtime types despite shared base</pre><p>C# 9 introduced records in 2020 to end the eternal class-vs-struct debate for immutable data. Guess even immutable data needed some family boundaries.</p><p><strong><em>Try it yourself (no setup required):</em></strong> <a href="https://dotnetfiddle.net/v0JlQc?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=record-inheritance-open-vs-sealed-hierarchies">https://dotnetfiddle.net/v0JlQc</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b52467f6777d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/records-have-family-drama-too-open-vs-sealed-inheritance-b52467f6777d">Records Have Family Drama Too: Open vs Sealed Inheritance</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Join vs GroupJoin: The LINQ Left Join Nobody Talks About]]></title>
            <link>https://medium.com/net-fiddle/join-vs-groupjoin-the-linq-left-join-nobody-talks-about-71db338bbaa8?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/71db338bbaa8</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 19:34:42 GMT</pubDate>
            <atom:updated>2026-09-10T19:34:42.666Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2g9lLw6hAa-xK6VM_TUW8Q.jpeg" /></figure><p>LINQ’s Join method has zero chill. If there’s no match, that record just vanishes. No warning, no trace. GroupJoin, on the other hand, keeps everyone in the room, even the ones who ordered nothing.</p><p>Join gives you a classic SQL inner join, only rows with matches survive. GroupJoin acts like a left join, grouping all matches (even zero) under each item on the left side.</p><pre>var innerJoin = customers.Join(orders, c =&gt; c, o =&gt; o.Customer,<br>(c, o) =&gt; $&quot;{c} ordered {o.Item}&quot;); // &lt;&lt;&lt; Join drops customers with zero matches<br><br>var leftJoin = customers.GroupJoin(orders, c =&gt; c, o =&gt; o.Customer,<br>(c, os) =&gt; $&quot;{c} ordered {(os.Any() ? string.Join(&quot;, &quot;, os.Select(o =&gt; o.Item)) : &quot;ghosted&quot;)}&quot;);</pre><p>Join arrived in LINQ back in .NET 3.5, when Microsoft decided querying collections should feel like SQL. GroupJoin came along for the ride, quietly handling the ‘what about the leftovers’ problem nobody asked about until they needed it.</p><p>Alice and Bob get their orders. The customer with no orders gets ghosted… unless you use GroupJoin.</p><p><strong><em>Try it yourself (no setup required):</em></strong> <a href="https://dotnetfiddle.net/Qdv5CJ?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=join-vs-groupjoin-inner-join-vs-left-join-in-linq">https://dotnetfiddle.net/Qdv5CJ</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71db338bbaa8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/join-vs-groupjoin-the-linq-left-join-nobody-talks-about-71db338bbaa8">Join vs GroupJoin: The LINQ Left Join Nobody Talks About</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SelectMany: The LINQ Trick That Ends Your Nested Foreach Loop Era]]></title>
            <link>https://medium.com/net-fiddle/selectmany-the-linq-trick-that-ends-your-nested-foreach-loop-era-ed053ac45dde?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed053ac45dde</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 08:34:30 GMT</pubDate>
            <atom:updated>2026-09-08T08:34:30.872Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVv1R2h9TsZncUQcU8UO8Q.jpeg" /></figure><p>Nested foreach loops called. They want a divorce.</p><p><strong>SelectMany</strong> flattens nested collections into one sequence with a single LINQ call. No temporary lists, no index juggling. orders.SelectMany(o =&gt; o.Items) hands you every item across every order in one flat sequence, like it’s nothing.</p><p>It’s been sitting in LINQ since .NET 3.5, back when Microsoft finally noticed developers hated writing double loops just to merge data. Someone on that team clearly got tired of List&lt;List&lt;T&gt;&gt; spaghetti.</p><pre>foreach (var item in orders.SelectMany(o =&gt; o.Items))<br>Console.WriteLine(item);</pre><p>First time I used this I felt like I’d unlocked a cheat code nobody told me about.</p><p><strong><em>See it in action:</em></strong> <a href="https://dotnetfiddle.net/hbpbk7?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=selectmany-flatten-nested-lists-in-one-linq-call">https://dotnetfiddle.net/hbpbk7</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed053ac45dde" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/selectmany-the-linq-trick-that-ends-your-nested-foreach-loop-era-ed053ac45dde">SelectMany: The LINQ Trick That Ends Your Nested Foreach Loop Era</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[nameof: The Operator That Never Forgets a Rename]]></title>
            <link>https://medium.com/net-fiddle/nameof-the-operator-that-never-forgets-a-rename-197ccfcd2af0?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/197ccfcd2af0</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Thu, 03 Sep 2026 12:50:40 GMT</pubDate>
            <atom:updated>2026-09-03T12:50:40.112Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JOxtJP74qDl7mgA8JSacOg.jpeg" /></figure><p>Ever renamed a variable and forgot to update the error message that mentioned it by name? Compiler didn’t care. Users got a lie.</p><p><strong>nameof</strong> is a C# operator that returns the string name of a variable, type, or member, resolved at compile time. No more hardcoded strings that quietly go stale the moment you refactor.</p><p>It landed in C# 6 (2015), specifically to kill magic strings in exceptions, logging, and property-changed events. Rename the variable, nameof follows along automatically. Rename a hardcoded string, and enjoy debugging that at 2am.</p><pre>static void Validate(object value, string paramName) {<br>  if (value == null) throw new ArgumentNullException(paramName);<br>}<br>Validate(userName, nameof(userName)); // survives renames</pre><p>No big joke here, it’s just quietly satisfying, like finally organizing your cables.</p><p><strong><em>Try it yourself (no setup required):</em></strong> <a href="https://dotnetfiddle.net/ls2jZ4?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=nameof-operator-refactor-safe-parameter-names">https://dotnetfiddle.net/ls2jZ4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=197ccfcd2af0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/nameof-the-operator-that-never-forgets-a-rename-197ccfcd2af0">nameof: The Operator That Never Forgets a Rename</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tuple Deconstruction: C#’s Cure for the Multi-Return Headache]]></title>
            <link>https://medium.com/net-fiddle/tuple-deconstruction-c-s-cure-for-the-multi-return-headache-7602399026c0?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/7602399026c0</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 13:32:39 GMT</pubDate>
            <atom:updated>2026-08-28T13:32:39.730Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-xk_7sp8qVVcttcv4ETEw.jpeg" /></figure><p><strong>Tuple deconstruction</strong> quietly ended the ugliest pattern in C#: methods littered with out int, out double, out whatever just to hand back more than one value.</p><p>Named tuples let a method return a real, labeled set of values, and you unpack them straight into locals at the call site. No wrapper class, no Dictionary&lt;string, object&gt;, no ceremony.</p><p>C# 7.0 (2017) added this combo of tuple literals plus pattern-based deconstruction, and multi-return methods stopped feeling like a workaround.</p><pre>static(int Total, double Average, int Max) AnalyzeCoffeeIntake(int[] cups) {…<br>  return (total, avg, max); // &lt;&lt;&lt; named tuple instead of out params<br>}<br>var (total, average, max) = AnalyzeCoffeeIntake(week); // &lt;&lt;&lt; deconstructed on the spot</pre><p>Microsoft took roughly a decade to admit returning three things shouldn’t require three arguments.</p><p><strong><em>Run it, break it, learn it:</em></strong> <a href="https://dotnetfiddle.net/JsXvq4?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=named-tuples-and-deconstruction-in-c-">https://dotnetfiddle.net/JsXvq4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7602399026c0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/tuple-deconstruction-c-s-cure-for-the-multi-return-headache-7602399026c0">Tuple Deconstruction: C#’s Cure for the Multi-Return Headache</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LINQ’s Aggregate: The Reducer That Makes Sum() Look Lazy]]></title>
            <link>https://medium.com/net-fiddle/linqs-aggregate-the-reducer-that-makes-sum-look-lazy-d99025a43d81?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/d99025a43d81</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 10:11:03 GMT</pubDate>
            <atom:updated>2026-08-26T10:11:59.460Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BcNB4TAVoHZzrbJA9ZRS7g.png" /></figure><p>Sum() and Count() are training wheels. <strong>Aggregate()</strong> is where LINQ actually lets you drive.</p><p>It’s LINQ’s general-purpose reducer: you hand it a seed and a function, and it folds your whole sequence into anything you want, not just a single number. Think building a running max with tie-breakers, folding prices into a receipt object, or tracking multiple stats in a single pass — all without a foreach loop in sight.</p><p>Aggregate shipped with LINQ in .NET 3.5 back in 2007, quietly doing the heavy lifting behind Sum and Count the whole time.</p><pre>var stats = bugsPerDay.Aggregate(<br>seed: (Total: 0, Max: int.MinValue, WorstDayIndex: -1, DayIndex: 0),<br>func: (acc, bugs) =&gt; (<br>Total: acc.Total + bugs,<br>Max: bugs &gt; acc.Max ? bugs : acc.Max,<br>WorstDayIndex: bugs &gt; acc.Max ? acc.DayIndex : acc.WorstDayIndex,<br>DayIndex: acc.DayIndex + 1<br>)); // &lt;&lt;&lt; one pass builds three running values at once</pre><p>Turns out Sum() was just Aggregate() wearing a trench coat this whole time.</p><p><strong><em>Try it yourself (no setup required):</em></strong> <a href="https://dotnetfiddle.net/nV1nvT?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=linq-aggregate-custom-reductions-beyond-sum-count">https://dotnetfiddle.net/nV1nvT</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d99025a43d81" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/linqs-aggregate-the-reducer-that-makes-sum-look-lazy-d99025a43d81">LINQ’s Aggregate: The Reducer That Makes Sum() Look Lazy</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GC.GetTotalMemory: The Cheapest Profiler You Already Have]]></title>
            <link>https://medium.com/net-fiddle/gc-gettotalmemory-the-cheapest-profiler-you-already-have-e535bf3d46d7?source=rss----4ab188f43763---4</link>
            <guid isPermaLink="false">https://medium.com/p/e535bf3d46d7</guid>
            <dc:creator><![CDATA[Andrey Tverdomed]]></dc:creator>
            <pubDate>Mon, 24 Aug 2026 11:38:38 GMT</pubDate>
            <atom:updated>2026-08-24T11:38:38.845Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLNsfGecUk4CVGnLkBQMRA.png" /></figure><p>Ever wonder how much garbage your code leaves behind before the GC quietly hauls it away? There’s a method that tells you, and it’s been sitting in .NET since version 1.0.</p><p><strong>GC.GetTotalMemory(bool forceFullCollection)</strong> returns roughly how many bytes are sitting on the managed heap. Call it before and after a chunk of code, subtract the two numbers, and you get a decent estimate of what you just allocated. It’s not lab-grade precision, but it’s free and it’s already in the BCL.</p><p>Microsoft’s own docs call the result “approximate,” which is corporate speak for “don’t quote us on this in court.”</p><p>Still, for catching a loop that’s quietly allocating a string per iteration, it’s more than good enough.</p><p><strong><em>See it in action:</em></strong> <a href="https://dotnetfiddle.net/mOqwKA?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=measuring-allocations-with-gc-gettotalmemory">https://dotnetfiddle.net/mOqwKA</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e535bf3d46d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/net-fiddle/gc-gettotalmemory-the-cheapest-profiler-you-already-have-e535bf3d46d7">GC.GetTotalMemory: The Cheapest Profiler You Already Have</a> was originally published in <a href="https://medium.com/net-fiddle">.NET Fiddle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>