$ curl cheat.sh/
/*
 * See `gjvdkamp`'s answer below; this feature now exists in C#
 * <hr>
 * I usually use a dictionary of types and delegates.
 */

 var @switch = new Dictionary<Type, Action> {
     { typeof(Type1), () => ... },
     { typeof(Type2), () => ... },
     { typeof(Type3), () => ... },
 };

 @switch[typeof(MyType)]();

/*
 * It's a little less flexible as you can't fall through cases, continue
 * etc. But I rarely do so anyway.
 * 
 * [Mark H] [so/q/4478464] [cc by-sa 3.0]
 */

$
Follow @igor_chubin cheat.sh