namespace WpfApplication3
{
public class Hex
{
public String terr;
}
public class HexC : Hex
{
int Cfield;
}
public interface IHexGrid
{
IEnumerable<Hex> hexs { get; }
}
public class hexGrid : IHexGrid //error CS0738: 'WpfApplication3.hexGrid' does not
{
public List<Hex> hexs { get; set; }
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<HexC> hexList1 = new List<HexC>();
genmethod(hexList1); //but this compiles fine
}
void genmethod(IEnumerable<Hex> hexList)
{
string str1;
foreach (Hex hex in hexList)
str1 = hex.terr;
}
}
}
The full error message is: 'WpfApplication3.hexGrid' does not implement interface member 'WpfApplication3.IHexGrid.hexs'. 'WpfApplication3.hexGrid.hexs' cannot implement 'WpfApplication3.IHexGrid.hexs' because it does not have the matching return type of 'System.Collections.Generic.IEnumerable'.
Why doesn't List implicitly cast to IEnumerable above? Thanks in advance!