public interface IDrawToFrom
{
void Draw();
}
public interface IDrawToMemory
{
void Draw();
}
public interface IDrawPrinter
{
void Draw();
}
public class Octagon : IDrawToFrom, IDrawToMemory, IDrawPrinter
{
void IDrawToFrom.Draw()
{
System.Console.WriteLine("drawing to form...");
}
void IDrawToMemory.Draw()
{
System.Console.WriteLine("drawing to memory...");
}
void IDrawPrinter.Draw()
{
System.Console.WriteLine("drawing to printer...");
}
}
class Program
{
static void Main(string[] args)
{
//通过显示接口实现解决命名冲突
Octagon oct = new Octagon();
((IDrawToFrom)oct).Draw();
((IDrawToMemory)oct).Draw();
((IDrawPrinter)oct).Draw();
}
}