public static void Main()
p.SetTestType(GetConfigType());
p.ConfiguredTest("Hello");
public static Type GetConfigType() { return typeof(string); }
Action<object> ConfiguredTest;
void SetTestType(Type type)
if (type == typeof(string))
ConfiguredTest = o => Test((string)o);
else if (type == typeof(int))
ConfiguredTest = o => Test((int)o);
if (ConfiguredTest != null)
Console.WriteLine("Unsupported type: " + o.GetType());
void Test(int i) { Console.WriteLine("Int = " + i); }
void Test(String s) { Console.WriteLine("String = " + s); }