In C#4.0, we have dynamic type, but how to invoke static method of dynamic type object?
Below code will generate exception at run time. The dynamic
One possible workaround would be to use reflection.
dynamic d = new Foo(); var sum = (int)d.GetType() .GetMethod("Sum") .Invoke(d, new object[] { 1, 3 }); Console.WriteLine(sum);