I am getting this error while compiling the code and not able to figure out the exact reason:
Class does not implement interface member
This is my code:
interface IReview<T> where T : Review
{
IEnumerable<T> Reviews { get; set; }
void AddReview<T>(T item);
}
class ReviewCollection : IReview<Review>
{
IEnumerable<Review> _reviews;
public IEnumerable<Review> Reviews
{
get { return _reviews; }
set { _reviews = value; }
}
public void AddReview(Review item)
{
}
}
What is the issue with it?
Your definition of AddReview
in the interface is wrong. It should read:
void AddReview(T item);
The generic type argument T
is already provided by the class, and you don't want to deviate in your method (in this case). You now changed the meaning of T
to be a local type parameter, not to use the one available on the class level.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments