program.cs

来自「这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代」· CS 代码 · 共 57 行

CS
57
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace _1
{
    public interface DoNet
    {
        void Drive();
    }
    //适配器
    public class CSharp : DoNet
    {
        public void Drive()
        {
            Console.WriteLine(".NET类库");
        }
    }
    // 改变
    public class CAspx
    {
        public void Web()
        {
            Console.WriteLine("可以开发Web应用程序,需要使用.NET类库!");
        }
    }
    // 实现类适配器
    public class CDriveAspx : CAspx, DoNet
    {
        public void Drive() { base.Web(); }
    }
    // 实现对象适配器
    public class CDriveAspx2 : DoNet
    {
        private CAspx aspx;

        public CDriveAspx2()
        {
            aspx = new CAspx();
        }

        public void Drive() { aspx.Web(); }
    }
    public class Client
    {
        public static void Main(string[] args)
        {
            DoNet donet = new CSharp();
            donet.Drive();
            donet = new CDriveAspx();
            donet.Drive();
            donet = new CDriveAspx2();
            donet.Drive();
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?