I have the below interface and concrete class.
I am getting an error of:
‘DAL.Model.Audit.Categories’ cannot implement ‘DAL.Interfaces.IAudit.Categories’ because it does not have the matching return type of ‘System.Collections.Generic.IEnumerable’.
Could anyone please explain what I am doing wrong here?
public interface IAudit
{
IEnumerable<ICategory> Categories { get; set; }
IEnumerable<IAuditAnswer> Answers { get; set; }
}
public class Audit : IAudit
{
public List<ICategory> Categories { get; set; }
public List<IAuditAnswer> Answers { get; set; }
}
You must respect the contract when implementing an interface:
In the interface the 2 properties are defined as
IEnumerable<T>, so in your implementing class you should use the same type instead ofList<T>.