📄 program.cs
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -