I am sure I am missing something simple, however I am trying to convert a strongly typed list of objects that all implement an interface in to a list of that interface type.
Below is a sample to demonstrate the error:
public void ExampleCode(){
List<Cube> cubes = new List<Cube>();
List<Shape> allShapes;
allShapes = cubes;//Syntax Error
allShapes = (List<Shape>)cubes;//Syntax Error
}
public class Cube : Shape
{
public int ID { get; set; }
public int Sides { get; set; }
}
public interface Shape
{
int ID { get; set; }
int Sides { get; set; }
}