How to invoke static method in C#4.0 with dynamic type?
- by Morgan Cheng
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.
class Foo
{
public static int Sum(int x, int y)
{
return x + y;
}
}
class Program
{
static void Main(string[] args)
{
dynamic d = new Foo();
…