Compilation Error: “The modifier 'public' is not valid for this item” while explicitly implementing the interface

后端 未结 5 1526
遥遥无期
遥遥无期 2020-12-02 16:33

I am getting this error while creating a public method on a class for explicitly implementing the interface. I have a workaround: by removing the e

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 16:59

    http://msdn.microsoft.com/en-us/library/aa288461(VS.71).aspx : When a member is explicitly implemented, it cannot be accessed through a class instance, but only through an instance of the interface.

    Customer customer = new Customer();
    

    Console.WriteLine(customer.PrintName());

    Violates this

提交回复
热议问题