PDA

Click to See Complete Forum and Search --> : Advanced used with generics-how to accomplish polymorphism with them?


PT Exorcist
Dec 31st, 2005, 07:54 AM
i have the following code public class ACollection : mCollection<int> {
}

public class BCollection : mCollection<long> {
}

public class mCollection<Y> : List<Y> {
}It is basically one generic mother class, and 2 classes that will inherit from that mother class. with that said, the problem i'm facing is that i have a function that will take one of those 2 classes, but will probably not know which one(and i dont really care for it).

the problem i'm facing is that i can't declare the mother class(as it is generic) without setting which type of generic data it will handle, and since i don't know what is the precise type of collection i will get im *****ed up.

any work around for this? ACollection col = new ACollection();
mCollection<"I WOULD HAVE TO DEFINE A TYPE HERE"> _mCol = col;