.NET Class Interface, Inheritance and Library: error does not implement interface member

I believe you had two errors here, didn't you? there should be an error saying that SetModel should have a body because IMyManager isn't an interface or an abstract class!

So, I believe you should have a body for that method, and then it has to be "public" since it's part of an implementation of an interface. And you should also rename IMyManager to be "MyManager", since it's not an interface. you should have your class like this:

public class MyManager : ILibManager
{
    public void SetModel(ILibModel model)
    {
        // implementation of SetModel
    }
}

Hope this helps :)


Try this instead:

namespace MyComponents
{
    public class MyManager : ILibManager
    {
        public void SetModel(ILibModel model)
        {
           // ...
        }
    }
}

A class that conforms to an interface (contract!) must implement it in a public manner.


You might also try explicit implementation, such as:

public class MyManager : ILibManager
{
    void ILibManager:SetModel(ILibModel model)
    {
        // ...
    }
}

Comments

  1. Dante

    • 2019/12/31

    I believe you had two errors here, didn't you? there should be an error saying that SetModel should have a body because IMyManager isn't an 

  2. Morgan

    • 2016/4/28

    namespace MyComponents { public class MyManager : ILibManager { public void SetModel(ILibModel model) { // } } } A class that conforms to an interface (contract!) must implement it in a public manner.

  3. Camden

    • 2019/9/11

    A class can implement interfaces that contain a member with the same signature in C#. Explicit implementation creates a class member 

  4. Louie

    • 2021/3/14

    Explicit Interface Implementation (C# Programming Guide) If a class implements two interfaces that contain a member with the same signature, then implementing that member on the class will cause both interfaces to use that member as their implementation. In the following example, all the calls to Paint invoke the same method.

  5. Mario

    • 2016/3/9

    An interface may not declare instance data such as fields, struct can implement multiple interfaces, but a class can only inherit from a 

  6. Montanari

    • 2017/7/4

    The ClassInterfaceType.None value prevents the class interface from being generated when the class metadata is exported to a type library. In the preceding example, COM clients can access the LoanApp class only through the IExplicit interface." 6. The next step is to modify the properties and methods signatures which we want to expose. So

  7. Colten

    • 2016/4/24

    NET types, interfaces never specify a base class (not even System.Object) and contain members that do not take an access modifier (as all interface members 

  8. Rodrigo

    • 2015/9/2

    If a class cannot reasonably implement a member of an interface, then the class is not the right fit for the interface. This may mean that the interface is poorly designed - probably trying to do too much - but that doesn't help the class.

  9. Brecken

    • 2016/4/1

    There is no concept of multiple-inheritance in Java, but, Interfaces in Java If a class implements an interface but does not implement one or more of 

  10. Salvatore

    • 2017/7/20

    There are two basic rules to follow when trying to implement interfaces and inherit from classes: A single class may implement as many interfaces as they like. A single class may only inherit from one other class. You might recall from the previous part of this series that C# does not permit multiple inheritance.

  11. Ignacio

    • 2016/11/17

    With this interface, you do not have to modify the class SimpleTimeClient , and this class (and any class that implements the interface TimeClient ) 

  12. Anthony

    • 2017/8/24

    Explicit interface implementation also allows the programmer to implement two interfaces that have the same member names and give each interface member a separate implementation. This example displays the dimensions of a box in both metric and English units.

  13. Issac

    • 2018/12/18

    Any class that implements the interface must support all the methods, or member prototype appears in the interface inheritance hierarchy, it is treated 

  14. Samir

    • 2015/1/19

    In either case, if there are no errors, an empty string value is At this point, you should understand the four interfaces implemented by editable 

Comments are closed.

Recent Posts