-
Notifications
You must be signed in to change notification settings - Fork 0
C Sharp
Since .NET 1.0 CTP 2 I have developed software in C#. Why? I was working a in Microsoft-oriented job developing user interfaces in VB6 so the DotNET framework was the natural way to go.
I embraced generics with .NET 2.0 but didn't fully appreciate the reification implementation until I starting using Java again which has implemented generics by type erasure.
I have written more lines of C# than any other language. My favourite features include:
-
iterators, i.e. the
yieldkeyword. This allows you to generate a sequence of data without having to have all the data in memory. I have used this feature to yield a sequence of tokens when implementing a parser. - LINQ brings higher order functions to the party, although I tend to use the LINQ extension methods rather than the query syntax.
-
structs are not widely used or appreciated feature. Want a non-nullable type? Use astruct. Want to return multiple values from a function? Use astruct.
Although its more of a DotNET framework feature, expression trees are interesting for a generating dynamic methods at runtime. I have used them to generate methods for an Excel-like language.
Extension methods that allow you to write methods that appear to extend a type. This allows you keep classes small and focused and add layers functionality via extension methods. Another benefit is you can define extension methods on interfaces, which of course is why they were introduced, for LINQ.
- Keep your classes and interfaces simple with minimal functionality
- Make your classes and interfaces easy to use with extension methods
© Chris Austin 2018-2024