<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Closures on Artur Rios Lab</title><link>https://lab.artur-rios.tech/tags/closures/</link><description>Recent content in Closures on Artur Rios Lab</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 21 Oct 2026 12:50:00 +0000</lastBuildDate><atom:link href="https://lab.artur-rios.tech/tags/closures/index.xml" rel="self" type="application/rss+xml"/><item><title>C# Delegates: Methods as Values</title><link>https://lab.artur-rios.tech/dotnet/delegates/</link><pubDate>Wed, 21 Oct 2026 12:50:00 +0000</pubDate><guid>https://lab.artur-rios.tech/dotnet/delegates/</guid><description>&lt;p&gt;&lt;code&gt;List&amp;lt;T&amp;gt;.Sort&lt;/code&gt; doesn&amp;rsquo;t know how you want your items ordered, so it asks you:&#10;pass it a method that compares two items, and it calls that method whenever it&#10;needs to. A button doesn&amp;rsquo;t know what should happen when it is clicked, so it&#10;keeps a list of methods to call. LINQ&amp;rsquo;s &lt;code&gt;Where&lt;/code&gt; doesn&amp;rsquo;t know which items you&#10;want, so it takes a method that answers yes or no for each one. All three&#10;need the same thing from the language: a way to treat &lt;em&gt;a method&lt;/em&gt; as a value&#10;that can be stored in a field, passed as an argument and called later. In C#&#10;that value is a &lt;strong&gt;delegate&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>