Anonymous types based in Interface
<p>Can I create anonymous implementations of an interface , in a way similar to the way </p>

<pre><code>delegate() { // type impl here , but not implementing any interface}
</code></pre>

<p>Something on the lines of </p>

<pre><code>new IInterface() { // interface methods impl here }
</code></pre>

<p>The situations where I see them to be useful are for specifying method parameters which are interface types, and where creating a class type is too much code.</p>

<p>For example , consider like this :</p>

<pre><code>    public void RunTest()
    {
        Cleanup(delegate() { return "hello from anonymous type"; });
    }

    private void Cleanup(GetString obj)
    {
        Console.WriteLine("str from delegate " + obj());
    }

    delegate string GetString();
</code></pre>

<p>how would this be achieved if in the above code , the method Cleanup had an interface as a parameter , without writing a class definition ?
( I think Java allows expressions like new Interface() ... )</p>
