"Class does not implement interface member" error on class implementing a generic interface

Akhil B

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?

Patrick Hofman

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Class does not implement interface member

From Dev

Xamarin jar binding error: Class does not implement interface member

From Dev

Fighter class does not implement interface member

From Dev

Instantiating generic class and implementing generic interface

From Dev

Generic class with an interface constraint vs class implementing interface

From Dev

Modifying value type in generic class implementing generic interface C#

From Dev

Query the generic type definition of a class implementing a generic interface

From Dev

Error implementing interface as anonymous inner class

From Dev

Kotlin class implementing Java interface error

From Dev

Implementing internal class with internal interface error

From Dev

Implementing a Generic Interface In Java

From Dev

How does adding an unused generic parameter to an interface stop a class implementing it?

From Dev

Implementing generic interface that takes a generic interface as a parameter

From Dev

Implementing a Generic Interface and a Non Generic Interface

From Dev

Implementing a Generic Interface and a Non Generic Interface

From Dev

Implementing Comparable with a generic class

From Dev

Why does a generic class implementing a generic interface with type constraints need to repeat these constraints?

From Dev

C# Generics : CS0311 when implementing generic class that meets a generic interface contract

From Dev

Anonymous class implementing an interface

From Dev

Base class implementing interface

From Dev

Generic C# class with limited types to some interface is not implementing other interface with member of the first one

From Dev

implementing a interface to a class: class to interface to interface

From Dev

Implementing Protocol In Generic class in swift

From Dev

Implementing a singleton in a generic Typescript class

From Dev

How can I obtain the type parameter of a generic interface from an implementing class?

From Dev

Why is my generic class constructor refusing to take objects implementing the requested Interface

From Dev

Implementing Java Interface with extra method in implementing Class

From Dev

Class design:class implementing an Interface implementing another interface

From Dev

Class design:class implementing an Interface implementing another interface

Related Related

  1. 1

    Class does not implement interface member

  2. 2

    Xamarin jar binding error: Class does not implement interface member

  3. 3

    Fighter class does not implement interface member

  4. 4

    Instantiating generic class and implementing generic interface

  5. 5

    Generic class with an interface constraint vs class implementing interface

  6. 6

    Modifying value type in generic class implementing generic interface C#

  7. 7

    Query the generic type definition of a class implementing a generic interface

  8. 8

    Error implementing interface as anonymous inner class

  9. 9

    Kotlin class implementing Java interface error

  10. 10

    Implementing internal class with internal interface error

  11. 11

    Implementing a Generic Interface In Java

  12. 12

    How does adding an unused generic parameter to an interface stop a class implementing it?

  13. 13

    Implementing generic interface that takes a generic interface as a parameter

  14. 14

    Implementing a Generic Interface and a Non Generic Interface

  15. 15

    Implementing a Generic Interface and a Non Generic Interface

  16. 16

    Implementing Comparable with a generic class

  17. 17

    Why does a generic class implementing a generic interface with type constraints need to repeat these constraints?

  18. 18

    C# Generics : CS0311 when implementing generic class that meets a generic interface contract

  19. 19

    Anonymous class implementing an interface

  20. 20

    Base class implementing interface

  21. 21

    Generic C# class with limited types to some interface is not implementing other interface with member of the first one

  22. 22

    implementing a interface to a class: class to interface to interface

  23. 23

    Implementing Protocol In Generic class in swift

  24. 24

    Implementing a singleton in a generic Typescript class

  25. 25

    How can I obtain the type parameter of a generic interface from an implementing class?

  26. 26

    Why is my generic class constructor refusing to take objects implementing the requested Interface

  27. 27

    Implementing Java Interface with extra method in implementing Class

  28. 28

    Class design:class implementing an Interface implementing another interface

  29. 29

    Class design:class implementing an Interface implementing another interface

HotTag

Archive