I want to define some generic class that
class A : IClonable
{
clone();
}
I want to define a new class that derivative from class T but base class of T is A ==> so if the new class is B i will be able to call to Clone without define the IClonable in class B again.
How can i do this ?
I think you’re asking how to make the clone method available on MyClass when T inherits from ICloneable. That’s not possible without explicity stating that MyClass also inherits from IClonable since MyClass isn’t inheritting from T; it’s simply a class which has methods / properties which in some way relate to T (i.e. allowing operations to be formed on classes of type T.
The closest I could come up with to allow you to access T through the generic class is to hack the default indexer property; that way by adding [1] to the end of your MyClass instance you’ll be looking at a single instance of a T clone.