interface IFoo
{
bool IsTasty { get; set; }
}
and a class that inherits from it:
class Bar : IFoo
{
private bool isTasty;
public Bar() { }
public bool IsTasty
{
get { return isTasty; }
set { isTasty = value; }
}
}
When I create a list of Bars:
List<Bar> bars = new List<Bar>();
bars.Add(new Bar());
which I wish to store inside an Array of the interface IFoo:
IFoo[] foos = new IFoo[12];
I can do the following:
foos[0] = bars[0];
but if I try and use the 'CopyTo' method, the type conversion fails:
bars.CopyTo(foos, 0);
Argument 1: cannot convert from 'Prototype1.IFoo[]' to 'Prototype1.Bar[]'
[/quote]
How can I get this to work correctly?