Trong thuật ngữ của giáo dân, nếu một lớp kế thừa từ 2 giao diện trở lên và nếu giao diện có cùng tên phương thức, lớp sẽ không biết phương thức giao diện nào đang được triển khai nếu bạn sử dụng giao diện ngầm. Đây là một trong các tình huống khi bạn thực hiện một giao diện rõ ràng.
Implicit Interface Implementtation
public class MyClass : InterfaceOne, InterfaceTwo
{
public void InterfaceMethod()
{
Console.WriteLine("Which interface method is this?");
}
}
interface InterfaceOne
{
void InterfaceMethod();
}
interface InterfaceTwo
{
void InterfaceMethod();
}
Explicit Interface Thực hiện
public class MyClass : InterfaceOne, InterfaceTwo
{
void InterfaceOne.InterfaceMethod()
{
Console.WriteLine("Which interface method is this?");
}
void InterfaceTwo.InterfaceMethod()
{
Console.WriteLine("Which interface method is this?");
}
}
interface InterfaceOne
{
void InterfaceMethod();
}
interface InterfaceTwo
{
void InterfaceMethod();
}
Các liên kết sau đây có một video tuyệt vời giải thích khái niệm này
Explicit Interface Implementation
Giải quyết xung đột ở đây ..... "Thực hiện Ngụ ý" - có nghĩa là thực hiện đơn giản một phương thức cụ thể có cùng tên và cùng một chữ ký thuộc cùng một lớp, trong đó có "Triển khai rõ ràng" - nghĩa là triển khai phương pháp bằng cách sử dụng Tên giao diện có cùng tên và chữ ký trong lớp cụ thể đó. –