title: Can anonymous class implement interface?
body: <p>Is it possible to have an anonymous type implement an interface?</p>
  
  <p>I've got a piece of code that I would like to work, but don't know how to do this.</p>
  
  <p>I've had a couple of answers that either say no, or create a class that implements the interface construct new instances of that. This isn't really ideal, but I'm wondering if there is a mechanism to create a thin dynamic class on top of an interface which would make this simple.</p>
  
  <pre><code>public interface DummyInterface
  {
      string A { get; }
      string B { get; }
  }
  
  public class DummySource
  {
      public string A { get; set; }
      public string C { get; set; }
      public string D { get; set; }
  }
  
  public class Test
  {
      public void WillThisWork()
      {
          var source = new DummySource[0];
          var values = from value in source
                       select new
                       {
                           A = value.A,
                           B = value.C + "_" + value.D
                       };
  
          DoSomethingWithDummyInterface(values);
  
      }
  
      public void DoSomethingWithDummyInterface(IEnumerable&lt;DummyInterface&gt; values)
      {
          foreach (var value in values)
          {
              Console.WriteLine("A = '{0}', B = '{1}'", value.A, value.B);
          }
      }
  }
  </code></pre>
  
  <p>I've found an article <a href="http://channel8.msdn.com/Posts/Adding-some-dynamic-to-C-interface-wrapping/" rel="noreferrer">Dynamic interface wrapping</a> that describes one approach. Is this the best way of doing this?</p>