title: c# Is it possible to supply a lambda when an interface is required?
body: <p>In some class method, A, I need to call a library method B, which takes as an <code>IProgress&lt;Object&gt;</code> as a parameter.</p>
  
  <p>Normally, I might  either implement <code>IProgress&lt;Object&gt;</code> as part of class where A resides, and then pass "this" to method B. Or perhaps I might create a new class whose only purpose is to implement <code>IProgress&lt;Object&gt;</code> and handle it correctly-- then in this case I'd create an instance of that class and pass it to B.</p>
  
  <p>But what I really want is to have my implementation of <code>IProgress&lt;Object&gt;</code> to appear right inside the method in which I'm calling B, so that there's less of a visual disconnect between the calling code, and the <code>IProgress&lt;Object&gt;</code> implementation.  (I consider my implementation of IProgress to be kind of a private, non-shared detail of the calling method and thus I don't want my implementation of <code>IProgress&lt;Object&gt;</code> to be in a whole separate method of perhaps a whole other class).</p>
  
  <p>What I've been trying to do is use a lambda in which I will define my short progress handling, and then somehow pass this lambda to B, like this:</p>
  
  <pre><code>method in class A {
  ...
  Action&lt;Object&gt; Report = (m) =&gt; { // do something useful with m };
  
  B(Report)
  }
  
  method B(IProgress&lt;Object&gt; reporter) {
     reporter.Report(some object)
  }
  </code></pre>
  
  <p>Of course, I know why this won't work as is - B is wanting an object that implements <code>IProgress&lt;Object&gt;</code> and I'm handing it an Action object instead.</p>
  
  <p>Is there any way to achieve what I'm trying to achieve? (IE have my implementation if <code>IProgress&lt;Object&gt;</code> appear inside method A?</p>