Display Interface implementation
If a class inherits multiple interfaces and interfaces have methods or attributes of the same name, you must use the display interface to avoid errors!
Example:
1 class Program
2 {
3 static void Main (string [] args)
4 {
5 MyClass a = new MyClass ();
6 a. show ();
7}
8}
9
10 class MyClass: Interface1, Interface2
11 {
12 public void show ()
13 {
14 Console. Write ("implementation interface ");
15}
16}
17
18 interface Interface1
19 {
20 void show ();
21}
22
23 interface Interface2
24 {
25 void show ();
26}
This should be changed:
Class Program
{
Static void Main (string [] args)
{
MyClass a = new MyClass ();
Interface1 B =;
B. show ();
}
}
Class MyClass: Interface1, Interface2
{
Void Interface1.show ()
{
Console. Write ("implementation interface 1 ");
}
Void Interface2.show ()
{
Console. Write ("implementation interface 2 ");
}
}
Actually, the location remains unchanged!
Note: display interface implementation. You cannot use class objects to call methods!