title: Equivalent of Java's anonymous class in C#?
body: <p>I am trying to port an SDK written in java to C#.</p>
  
  <p>In this software there are many "handler" interfaces with several methods (for example: <code>attemptSomethingHandler</code> with <code>success()</code> and several different failure methods). This interface is then implemented and instantiated anonymously within the calling class and passed to the <code>attemptSomething</code> method of the <code>SomethingModel</code> class. This is an async method and has several places where it could fail or calls another method (passing on the handler). This way, the anonymous implementation of <code>attemptSomethingHandler</code> can reference private methods in the class that calls <code>attemptSomething</code>.</p>
  
  <p>In C# it is not possible to anonymously implement an interface. I could explicitly implement a new class, but this implementation would be unique to this calling class and not used for anything else. More importantly, I would not be able to access the private methods in the calling class, which I need and do not want to make public.</p>
  
  <p>Basically, I need to run different code from the calling class depending on what happens in the <code>SomethingModel</code> class methods.</p>
  
  <p>I've been reading up on delegates but this would require passing as many delegates as there are methods in the handler interface (as far as I can tell).
  What is the appropriate way to do this in C#? I feel like I'm missing out on a very common programming strategy. There simply must be an easy, clean way to structure and solve this problem.</p>