Let me start by saying I'm pretty new to using interfaces.
I'm writing a method (GetClaimDetails) that will return information about a medical insurance claim. If it is claim type A, it will return an list of the ClaimDetailA class. If claim type B, return list of ClaimDetailB class. Both of these classes share common properties but each have unique properties. The common properties are implemented in an interface.
I extracted an interface named IClaimDetail and set both to implement it. When i set the method to return IClaimDetail and have it return an instance of an object that implements IClaimsDetail, I get the compiler message
'Cannot implicitly convert type 'System.Collections.Generic.List DentalClaimDetail' to 'System.Collections.Generic.List IClaimDetail'
private static List<IClaimDetail> GetClaimDetailsB(string claimNumber, string connectionStringName)
{
var claimReportRows = new List<DentalClaimDetail>();
..removed for brevity
return claimReportRows;
}
public class DentalClaimDetail : IClaimDetail
{
...
}
When a method returns an interface, you just return an object the implements the interface. Correct? What am I doing wrong?