This is Listing 6 program in the following website (http://www.developer.com/net/csharp/article.php/1482651/Working-with-Interfaces-in-C.htm).
The program is not executing. Please fix the error.
//Listing 6
using System;
interface Interdemo
{
void Show();
}
interface Interdemo1
{
void Show();
}
class Interclash : Interdemo, Interdemo1
{
void Interdemo.Show()
{
Console.WriteLine("Show() method Implemented");
}
void Interdemo1.Show()
{
Console.WriteLine("Display() method Implemented");
}
public static void Main(string[] args)
{
Interclash inter = new Interclash();
inter.Interdemo.Show();
inter.Interdemo1.Show();
Console.ReadKey();
}
}
Loading
VulpesPosted Aug 17, 2012, 10:30 AM
As the two Show() methods are implemented using 'explicit interface implementation', you have to cast 'inter' to the interface type before you can call them.
Posted Aug 17, 2012, 10:34 AM