Dinesh Kumar
What is explicit and implicit interface and in which condition we should use ?
By Dinesh Kumar in .NET on Apr 03 2015
  • Madhuri Mishra
    May, 2015 1

    Let's say your one class -> implement two interface (I1 and I2 - having same method name A() )-> it can create conflicts with your requirements-> so to overcome this instead of implicit interface you use explicit interface.For using explicit interface -> you need to add fully qualified method name with interface in your class.For ex instead of using only A() you need to write I1.A() in your class

    • 3
  • Prakash Tripathi
    Apr, 2015 22

    In simple words, When you implement the member of the interface in the class without specifying the interface name, then it's called as Implicit interface implementation. On the other side, if you are creating the object of interface then calling it's method then it's explicit implementation.Below is the simple example which explains the same.interface ITest{void TestMethod();}class TestClass: ITest{public void TestMethod(){Console.WriteLine("Implicit Interface Implementation");}void ITest.TestMethod(){Console.WriteLine("Explicit Interface Implementation");}}class Program{static void Main(string[] args){TestClass obj = new TestClass();obj.TestMethod(); //Way to call implicitely implemented methodITest obj2 = new TestClass();obj2.TestMethod();Console.ReadLine();}}Just to add the constraint with explicit implementation is that explicitly implemented member cannot be accessed through a class instance, but only through an instance of the interface. You can see the same in example above.

    • 3
  • Sujeet Suman
    Jun, 2015 18

    Implementing interface members with interface name is called explicit interface where as without interface name is called implicit interface.In common situation we use implicit interface. But when a class implement 2 or more interface having same method signature at that moment we use explicit interface.

    • 2
  • Neeraj Upadhyay
    May, 2015 26

    When you implement the some member of interface in your class without specifying your interface name that is called implicit interface else if you implement the some member of interface in your class with their fully qualified path means interface name and method name with dot this is called explicit interface

    • 1
  • sanjib kotal
    Jul, 2016 9

    When the Interface methods are publicly declared they are called Explicit interfaces; where as when the interface methods are declared privately, they are said to be implicit Interfaces

    • 0
  • Rajesh Singh
    Dec, 2015 5

    https://msdn.microsoft.com/en-us/library/aa288461(v=vs.71).aspx

    • 0
  • Pankaj  Kumar Choudhary
    May, 2015 14

    In Implicit interface we simply inherit the method of a Interface with out using interface name but when use a interface name before method name in abstract class then it is known as Explicit interface . An Explicit interface we can not call method of a interface using class object .. We should be create a instance of Interface that will hold a reference of class object

    • 0
  • Munesh Sharma
    Apr, 2015 16

    http://www.c-sharpcorner.com/UploadFile/8911c4/implicit-and-explicit-interface-examples/

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS