Monday, 30 September 2013

Replace a base class with a concrete implementation C#

Replace a base class with a concrete implementation C#

I have the fallowing abstract class and interface
public interface ITypedEntity{
TypedEntity Type { get; set; }
}
public abstract class TypedEntity:INamedEntity{
public abstract int Id{get;set;}
public abstract string Name { get; set; }
}
But when i try to make a create a class that implements ITypedEntity and
has a concrecte implementation of TypedEntity i get the fallowing error
Magazine does not implement interface member ITypedEntity.Type.
Magazine.Type cannot implement 'ITypedEntity.Type' because it does not
have the matching return type of 'TypedEntity'
The code for my concrecte implementation is bellow
public class Magazine:INamedEntity,ITypedEntity
{
public int Id {get;set;}
[MaxLength(250)]
public string Name {get;set;}
public MagazineType Type { get; set; }
}
public class MagazineType : TypedEntity
{
override public int Id { get; set; }
override public string Name { get; set; }
}
I think i understand what is happening but i don't know why because
MagazineType is a TypedEntity.
Thanks.

No comments:

Post a Comment