Having defined the following:
public interface IFoo { }
public interface IBar<IFoo> { }
public class Foo : IFoo { }
public class Bar : IBar<Foo> { }
This line throws error:
IBar<IFoo> test = (IBar<IFoo>) new Bar();
"Unable to cast object of type 'Bar' to type 'IBar'1[IFoo]'
Why is that? How can I resolve this issue?