Home >Backend Development >C#.Net Tutorial >What is implicit implementation of interfaces and when to use implicit implementation of interfaces in C#?
C# Interface members can be implemented explicitly or implicitly.
Implicit implementation does not include the name of the interface being implemented before the member name, so the compiler infers this. These members will be exposed as public and accessible when the object is converted to a concrete type. The invocation of the
method is no different. Just create an object of this class and call it.
If the same method name is declared in multiple interfaces, you cannot use an implicit interface
interface ICar { void displayCar(); } interface IBike { void displayBike(); } class ShowRoom : ICar, IBike { public void displayCar() { throw new NotImplementedException(); } public void displayBike() { throw new NotImplementedException(); } } class Program { static void Main() { ICar car = new ShowRoom(); IBike bike = new ShowRoom(); Console.ReadKey(); } }
The above is the detailed content of What is implicit implementation of interfaces and when to use implicit implementation of interfaces in C#?. For more information, please follow other related articles on the PHP Chinese website!