I would like to pass a method a List of a custom type that conforms to an interface. I'd like the method parameter to be a List of the particular interface type.
Is this possible? I can see I can do this if I use an array instead of a List. I've added my code below to help clarify my problem.
public interface TeamMoveCTRL_IF
{
}
public class TeamMember: TeamMoveCTRL_IF
{
}
public class TeamCTRL
{
public TeamMember[] team1;
public List<TeamMember> team2;
void Start()
{
TestArray(team1); //Works
TestListElement(team2[0]); //Works
TestList(team2); //Error because team2 is List<TeamMember>
}
private void TestList(List<TeamMoveCTRL_IF> team )
{
}
private void TestArray(TeamMoveCTRL_IF[] team)
{
}
private void TestListElement(TeamMoveCTRL_IF member)
{
}
}