Search This Blog

Thursday, March 25, 2010

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

Programmer Question

Here's the story. I created an 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?



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails