Hi,
Have class B which subclasses from class A. I have a List<B> and I'm
trying to get a List<A> without writing a stupid loop everytime I want
to do it. So I tried this method:
public static List<Destination> ConvertList<Source,
Destination>(List<Source> sourceList) where Destination : Source
{
List<Destination> result = new List<Destination>();
foreach (Source aSource in sourceList)
{
result.Add(aSource as Destination);
}
return result;
}
It didn't work, is it possible?
Why isn't there a method like this:
List<B> aList = new List<B>();
List<A> newList = aList.Convert<A>();
Any ideas?
Thanks,