In java it's possible to dynamically implement an interface using a dynamic proxy, something like this:
public static <T> T createProxy(InvocationHandler invocationHandler, Class<T> anInterface) {
if (!anInterface.isInterface()) {
throw new IllegalArgumentException("Supplied interface must be an interface!");
}
return (T) Proxy.newProxyInstance(anInterface.getClassLoader(), new Class[]{anInterface}, invocationHandler);
}
Is there an equivalent in .Net?