<story><title>Hidden features of C#</title><url>http://stackoverflow.com/questions/9033/hidden-features-of-c</url></story><parent_chain></parent_chain><comment><author>jb55</author><text>One powerful feature I don&apos;t see being used very often is simulating typeclasses via contraints on generic types:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    public static IEnumerable&amp;#60;CalculatedTax&amp;#62; CalculateTaxes&amp;#60;T&amp;#62;(this T t)
      where T : IOrderItems, IAddress {}
&lt;/code&gt;&lt;/pre&gt;
This adds an extension method to any type that implements those interfaces. Using this technique I have been able to make my interfaces much smaller and have generic functions which apply to many different types.&lt;p&gt;Here&apos;s what it would might look like in Haskell:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    calculateTaxes :: (OrderItems a, Address a) =&amp;#62; a -&amp;#62; [CalculatedTax]&lt;/code&gt;&lt;/pre&gt;</text></comment>
<story><title>Hidden features of C#</title><url>http://stackoverflow.com/questions/9033/hidden-features-of-c</url></story><parent_chain></parent_chain><comment><author>rnemo</author><text>I would hope most C# developers are aware of most of these features and how they facilitate the writing of good C# code, but this article seems like a good jumping off point for gaining greater understanding of the nuances of C#.&lt;p&gt;A better title to this article would have been &quot;Less Understood Features of C#,&quot; as things like nullable types, boxing and unboxing using as/is, readonly variables, Nullable&amp;#60;T&amp;#62;, type inferrence and most of the rest of the articles content should not be hidden to anyone who intends to have more than passing knowledge of the language. Most of the things mentioned by the post benefit from having the additional explanation so they can be understood well though.</text></comment>