title: How to invoke static method in C#4.0 with dynamic type?
body: <p>In C#4.0, we have dynamic type, but how to invoke static method of dynamic type object?</p>
  
  <p>Below code will generate exception at run time. The <strong>dynamic</strong> object is from C# class, but it could be object from other languages through DLR. The point is not how to invoke static method, but how to invoke static method of <strong>dynamic</strong> object which could not be created in C# code.</p>
  
  <pre><code>class Foo
  {
      public static int Sum(int x, int y)
      {
          return x + y;
      }
  }
  
  class Program
  {
  
      static void Main(string[] args)
      {
          dynamic d = new Foo();
          Console.WriteLine(d.Sum(1, 3));
  
      }
  }
  </code></pre>
  
  <p>IMHO, <strong>dynamic</strong> is invented to bridge C# and other programming language. There is some other language (e.g. Java) allows to invoke static method through object instead of type. </p>
  
  <p>BTW, The introduction of C#4.0 is not so impressive compared to C#3.0.</p>