//Convert the interface of a class into another interface expect. //Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. static void Main(string[] _) { IMemory camera = new CameraMemory(); IMemory sd = new SdCardMemoryAdapter(new SdCardMemory()); camera.Connect(); camera.GetData(); camera.SetData(); Console.WriteLine("----------------"); sd.Connect(); sd.GetData(); sd.SetData(); Console.ReadLine(); }
static void Main(string[] args) { IMemory cameraMemory = new CameraMemory(); IMemory sdCardMemor = new SDCardMemoryAdapter(); Console.WriteLine("The Camera Memory"); Console.WriteLine("---------------------"); cameraMemory.Connect(); Console.WriteLine("\n"); Console.WriteLine("The SDCard Memory"); Console.WriteLine("---------------------"); sdCardMemor.Connect(); Console.ReadKey(); }