Why can't I call methods within a class that explicitly implements an interface?

Posted by tyrone302 on Stack Overflow See other posts from Stack Overflow or by tyrone302
Published on 2010-03-26T01:54:49Z Indexed on 2010/03/26 2:03 UTC
Read the original article Hit count: 451

Here's the story. I created and interface, IVehicle. I explicitly implemented the interface in my class, Vehicle.cs.

Here is my interface:

Interface IVehicle
{
        int getWheel();
}

here is my class:

class Vehicle: IVehicle
{

     public int IVehicle.getWheel()
     {
         return wheel;
     }

     public void printWheel()
     {
         Console.WriteLine(getWheel());
     }
}

Notice that "getWheel()" is explicitly implemented. Now, when I try to call that method within my Vehicle class, I receive an error indicating that getWheel() does not exist in the current context. Can someone help me understand what I am doing wrong?

© Stack Overflow or respective owner

Related posts about c#

Related posts about explicit