Compiler says I am not implementing my interface, but I am?

后端 未结 7 1461
無奈伤痛
無奈伤痛 2021-02-13 14:03

Okay, I have two namespaces. One contains my interface and one contains the implementing class. Like this:

namespace Project.DataAccess.Interfaces
{
    public i         


        
7条回答
  •  [愿得一人]
    2021-02-13 14:30

    Methods implementing interface needs to be public. In your later case, you are declaring it explicitly. This is what specification says about explicit interface implementation.

    Explicit interface member implementations have different accessibility characteristics than other members. Because explicit interface member implementations are never accessible through their fully qualified name in a method invocation or a property access, they are in a sense private. However, since they can be accessed through an interface instance, they are in a sense also public.

提交回复
热议问题