I have 3 different classes, a generic "entity" class, and then two classes that inherit this, a bullet class and an enemy class.
I then have a list of the entity class, with the bullets and enemies in the list, and a lot of the places I treat these the same. However, some times, I want to loop through just one of the classes, and not the other, e.g. Loop through each bullet, but not the enemies. Is there any way to do this?
I tried
foreach (Bullet tempBullet in entities)
But I get the error
Unable to cast object of type 'Enemy' to type 'Bullet'.
Anyone know if this is possible, or do I have to use seperate lists?