I try to create a generic interface that inherits the System.ICloneable interface but where the returntype of the Clone()-method is T. Of course the T-type needs constraints to be sure it's an inheritance of the System.Object-class but the following code is not working.
public interface ICloneable<T> : System.ICloneable where T : object {
T Clone ();
}
What am I doing wrong?
Also the following constraints don't work:
- where T : System.Object
- where T : class
how can I use the Liskov-principle in this case that says that you can narrow your return type, to solve this problem?
P.S.: Sorry for my English, if i made mistakes. I'm not a native English speaker.