Just an interesting side-note:
While not possible conceptually, syntactically it is indeed possible to instantiate an interface under specific circumstances.
.NET has something called a CoClassAttribute which tells the compiler to interpret marked interface as specified concrete type. Using this attribute would make the following code perfectly valid and not throw a compile time error (note that this is not an array as in the original post):
var x = new IDynamicCode<string>();
A typical declaration of such attribute would look like this:
[ComImport]
[Guid("68ADA920-3B74-4978-AD6D-29F12A74E3DB")]
[CoClass(typeof(ConcreteDynamicCode<>))]
public interface IDynamicCode<out TCodeOut>
{
object DynamicClassInstance { get; set; }
TCodeOut Execute(string value = "");
}
Should this attribute be ever used and if, then where? The answer is "mostly never"! However, there are a couple of scenarios specific to COM interop where this will provide to be a useful feature.
More can be read about the topic from the following links: