Skip to content

Instantly share code, notes, and snippets.

@shanefulmer
Created July 20, 2012 12:57
Show Gist options
  • Select an option

  • Save shanefulmer/3150597 to your computer and use it in GitHub Desktop.

Select an option

Save shanefulmer/3150597 to your computer and use it in GitHub Desktop.
Dynamic Dispatch 5
using System;
using System.Collections.Generic;
public class Foo { }
public class Bar { }
public class Baz { }
public class Program
{
public static void CallMe<T>(T input)
{
Console.WriteLine("typeof(T): {0}", typeof(T));
}
static void Main()
{
var objects = new List<object>();
objects.Add(new Foo());
objects.Add(new Bar());
objects.Add(new Baz());
foreach (var o in objects)
{
Program.CallMe((dynamic)o);
}
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment