This post is written by guest blogger Albin Sunnanbo. He’s a great friend and source of inspiration and also one of the best developers I know. It was Albin that first introduced me to LINQ, EF Migrations and jQuery that I now use daily. Sometimes you use Tuple<T1, T2> in C# to store results of… Continue reading Creating an Empty List<AnonymousType>
Tag: yield return
Bitten by yield return
I like the simplicity of creating enumerations with iterator blocks through yield return. Even though I regularly do it, I was bitten by a nasty bug a few weeks ago and it was entirely my own fault. I had been working hard on my bar management system, which includes a service to book a bar… Continue reading Bitten by yield return
Return IEnumerable with yield return
Ever needed to return an IEnumerable<T> from a method? Did you create a List<T> instance that you populated and returned? There is a better way, with less memory footprint and better performance. The yield return statement is one of the more mysterious, yet very useful constructs in C#. With yield return it is possible to… Continue reading Return IEnumerable