Explicit Implimentation

What do you mean by Explicit Interface Implimentation? What's Interface Mapping?

Questions by chandra_123   answers by chandra_123

Showing Answers 1 - 12 of 12 Answers

cocojojo

  • Apr 23rd, 2009
 

A class that implements an interface can explicitly implement a member of that interface. When a member is explicitly implemented, it cannot be accessed through a class instance, but only through an instance of the interface

When class implement interface, user mandatory needs to specify interface method body. Such implementation is called as Exlicit
implementation. All the signature of interface API must be compatible with interface API. Dervice class can also define their
own API.

  Was this answer useful?  Yes

RajMarandi

  • Oct 23rd, 2009
 

interface I1
{
     void someMethod();
}
Interface I1
{
    void someMethod();
}
 
class someClass:I1,I2
{
  void I1.someMethod()
  {
       //This is called explicit implementation as  i am telling the compiler to implement someMethod of interface I1
  }
  void I2.someMethod()
  {
       //This is called explicit implementation of someMethod of I2 interface
  }
}


  Was this answer useful?  Yes

azita2005

  • Apr 5th, 2010
 

If we have a class inherits from interface, we need to implements the members of that
interface. It is possibe with explicitly or implicitly way.
 
In Explicit way,  through the interface we can access to that member.

For example:

interface IDrivable
{
    void Start();
}

class Car : IDrivable
{
    void IDrivable.Start()
    {
        Console.WriteLine("IDrivable.Start");
    }
}

Car car1 = new Car();
IDrivable iDrivable1 = (IDrivable)car1;
iDrivable1.Start();

Using explicitly interface is necessary when one class implement multiple interfaces with conflicting member definitions.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions