适配器模式

using System;

namespace MyApp

{

class Program

{

static void Main()

{

ITarget target = new Adapter();

target.TheMethod();

Console.ReadKey();

}

}

class Adaptee

{

public void MyMethod()

{

Console.WriteLine("The method of Adaptee...");

}

}

interface ITarget

{

void TheMethod();

}

class Adapter : Adaptee,ITarget

{

public void TheMethod()

{

MyMethod();

}

}

}

你可能感兴趣的:(适配器模式)