using System.IO;
using System;
namespace 代理模式
{
class Program
{
static void Main(string[] args)
{
Proxy p = new Proxy("一些字段");
p.DoSomething1();
p.DoSomething2();
Console.Read();
}
interface IDoSomething
{
void DoSomething1();
void DoSomething2();
}
class Major : IDoSomething
{
string yield;
public Major(string yield)
{
this.yield = yield;
}
public void DoSomething1()
{
Console.WriteLine(yield + "~做事1");
}
public void DoSomething2()
{
Console.WriteLine(yield + "~做事2");
}
}
class Proxy : IDoSomething
{
Major m;
public Proxy(string yield)
{
m = new Major(yield);
}
public void DoSomething1()
{
m.DoSomething1();
}
public void DoSomething2()
{
m.DoSomething2();
}
}
}
}
C#设计模式学习小结之十 代理模式
最新推荐文章于 2024-09-06 10:11:01 发布