I have 2 base classes FirstBase and SecondBase. I also have 2 class derive from them, DerivedFirst and DerivedSecode and both of them has almost of same property. Source code is like below.
public abstract class FirstBase
{
//some method
}
public abstract class SecondBase
{
//some method
}
public class DerivedFirst : FirstBase
{
//override methods of its parent
public static implicit operator DerivedFirst(DerivedSecond second)
{
//doing some logic here
}
}
public class DerivedSecond : SecondBase
{
//override methods of its parent
public static implicit operator DerivedSecond(DerivedFirst first)
{
//doing some logic here
}
}
From this code I can create instance of DerivedFirst and assign to DerivedSecond without any problem. However when I try to convert list of them like code below, It has no result.
List<DerivedFirst> firstList;
List<DerivedSecond> secondList;
//doing some operation here
List<DerivedSecod> test = firstList.Cast<DerivedSecond>(); // don't have any output here.
How can I convert firstList to List()?