IEnumerable and IEnumerable(Of T) 2

Quick follow up to my earlier post.  Fixing this issue in C# is even easier because of the existence of iterators.  public static IEnumerable<object> Shim(System.Collections.IEnumerable enumerable) { foreach (var cur in enumerable) { yield return cur; } }

3

IEnumerable and IEnumerable(Of T)

IEnumerable(Of T) is a huge step up in the 2.0 framework from the original IEnumerable interface.  It provides a typed enumeration which eliminates lots of nasty casts.  The best part is that IEnumerable(Of T) is backwards compatible with IEnumerable (it inherits from it).  What’s frustrating is that IEnumerable is not forwards compatible with IEnumerable(Of Object). …

4

Casting to an Anonymous Type

This discussion is building upon a previous post on how to acquire an anonymous type … type.  The next question is, how can you cast an arbitrary object into an anonymous type?  At a glance this doesn’t seem possible as you cannot directly express the type of an anonymous type in code.  For instance the…

4

Singleton Pattern

Quite awhile back I posted about how to create a re-usable singleton pattern in .Net.  Link is here.  A bit of time has passed and I’ve altered the pattern a bit.  The reasons for the change are some new type inference patterns and FxCop cleanliness.  The first pattern I introduced had a couple of FxCop…

3