Saturday, April 18, 2009

Instatiating an Interface

Recently, I found out that there is a way for “Instantiating an interface” in C#. Here is the code.

[ComImport]
[Guid("DC1CB768-0BE5-4200-8D0A-C844BFBE3DE7")]
[CoClass(typeof(Foo))]
interface IFoo
{
}
class Foo : IFoo
{
}

static void Main(string[] args)
{
    // Instatiating an Interface --- This works
    IFoo foo = new IFoo();
}

Please let me know your comments.

No comments:

Post a Comment