为了实现统一
- interface IPrint
- {
- void Display();
- }
- class Print1 : IPrint
- {
- #region IPrint 成员
- public void Display()
- {
- Console.WriteLine("print1");
- }
- #endregion
- }
- class Show1
- {
- public void ShowWord()
- {
- Console.WriteLine("show1");
- }
- }
开始适配
- class Print2:IPrint
- {
- #region IPrint 成员
- private Show1 show1 = new Show1();
- public void Display()
- {
- show1.ShowWord();
- }
- #endregion
- }
- class Program
- {
- static void Main(string[] args)
- {
- //IPrint print = new Print1();
- IPrint print = new Print2();
- print.Display();
- Console.Read();
- }
- }