I'm trying to search a list for implementations of an interface, but cannot figure the syntax out for finding specific implementations.
What I have basically looks like this:
public interface IVehicle
{
void Speed()
void Weight()
}
Public class Car : IVehicle
{
}
Another example of an IVehicle would be
public class Truck : IVehicle
{
}
In this class I have a list of IVehicles that I would like to find Car from.
Public class Road
{
List<IVehicle> vehicles = new List<IVehicle>();
void SomeMethod()
{
vehicles.Add(new Car);
}
}
Any help would be greatly appreciated. What is off about my syntax? I've managed to pull Car out, if I make sure to hit the precise index, and the methods run correctly, but I'd like to not have to add in a classes to the List while insuring a precise order is followed. For instance, at one point I want to pull Car out but not Truck. Thanks in advance.