I have an interface ID, which is derived from another interface IB.
public interface IB
{
int Num { get; }
}
public interface ID : IB
{
}
Let's say we have a class that implements ID:
public class DImpl : ID
{
public int Num { get; set; }
}
I know that I can call a function that receives IB with a variable that is held as ID.
public void FuncOfIB(IB b)
{
// do something
}
public static void Main()
{
ID d = new DImpl();
FuncOfIB(d); // Works
}
I would like to call a function that receives a List<IB>
as a parameter:
void ProcessListOfIB(List<IB> list)
{
// Some code
}
But it seems that I can't call this function with List<ID>
.
public static void Main()
{
List<ID> listID = new List<ID>();
ProcessListOfIB(listID); // Doesn't work
}
Does anyone know why? And how can I fix it? thank you.
Edit: I need the function ProcessListOfIB
to remove an item from the list, so copying doesn't solve my problem...