F
ffimbel
Hi,
Today I ran into an issue using interface and generic list.
Here is a sample of code to illustrate the issue.
I have two interfaces and two concrete classes (simplifed for sake of
simplicity)
public interface IField
{
String Name
{ get;}
}
public interface IStructure
{
IList<IField> Fields{get;}
}
public class FillerField: IField
{
private String _name;
public String Name
{
get { return _name; }
set { _name= value; }
}
}
public class FillerStructure:IStructure
{
private IList<FillerField> _fields;
public IList<FillerField> Fields
{
get { return _fields; }
set { _fields = value; }
}
}
When I try to compile I get an error stating that FillerStructure
doesnt implement
IStructure interface.
If I change public IList<FillerField> Fields method signature to it's
interface based public IList<IField> Fields it works.
Any idea why it's preventing to compile in the first place ?
Thanks in advance for your help
Today I ran into an issue using interface and generic list.
Here is a sample of code to illustrate the issue.
I have two interfaces and two concrete classes (simplifed for sake of
simplicity)
public interface IField
{
String Name
{ get;}
}
public interface IStructure
{
IList<IField> Fields{get;}
}
public class FillerField: IField
{
private String _name;
public String Name
{
get { return _name; }
set { _name= value; }
}
}
public class FillerStructure:IStructure
{
private IList<FillerField> _fields;
public IList<FillerField> Fields
{
get { return _fields; }
set { _fields = value; }
}
}
When I try to compile I get an error stating that FillerStructure
doesnt implement
IStructure interface.
If I change public IList<FillerField> Fields method signature to it's
interface based public IList<IField> Fields it works.
Any idea why it's preventing to compile in the first place ?
Thanks in advance for your help