tags:

views:

52

answers:

1

I have an interface as follows:

 public interface ISelectEntity
{
    List<T> GetFromDB<T, O>(O data);
}

I'm implementing it as follows within a StatusCodes class

List<StatusCodes> ISelectEntity.GetFromDB<StatusCodes, StatusCodesInputParameters>(StatusCodesInputParameters data)
    {
        return EntitiesClass.PopulateStatusCodes(EntitiesDAL.GetStatusCodes(data));
    }

I'm receiving the following error, however:

Error 2 Argument '1': cannot convert from 'StatusCodesInputParameters' to 'Namespace.StatusCodesInputParameters'

Assuming that my namespace is called Namespace, that's the error I receive. All of this is within this one namespace. What am I doing wrong?

+1  A: 

You cannot change method signatures in derived classes. You could define the generic argument on the interface though instead of doing it on the method:

public interface ISelectEntity<T, O>
{
    List<T> GetFromDB(O data);
}

and a sample explicit implementation might look like this:

public class Foo : ISelectEntity<StatusCodes, StatusCodesInputParameters>
{
    List<StatusCodes> ISelectEntity<StatusCodes, StatusCodesInputParameters>.GetFromDB(StatusCodesInputParameters data)
    {
        return EntitiesClass.PopulateStatusCodes(EntitiesDAL.GetStatusCodes(data));
    }
}

and a sample implicit implementation:

public class Foo : ISelectEntity<StatusCodes, StatusCodesInputParameters>
{
    public List<StatusCodes> GetFromDB(StatusCodesInputParameters data)
    {
        return EntitiesClass.PopulateStatusCodes(EntitiesDAL.GetStatusCodes(data));
    }
}
Darin Dimitrov
Thank you very much! I didn't realize.
DougJones