惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
月光博客
月光博客
IT之家
IT之家
B
Blog RSS Feed
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - Franky
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
博客园_首页
B
Blog
V
V2EX
腾讯CDC
Vercel News
Vercel News
量子位
Microsoft Security Blog
Microsoft Security Blog

博客园 - AnsonWu

[转载]Remoting随想 [转]Remoting之同步—异步调用 [转]正则表达式30分钟入门教程 准备写一个智能提示的控件,大家有什么好的思路 javascript函数库 推荐一个免费的数据库开发工具 从WEB SERVICE 中数据压缩策略(转) Asp.net Ajax 关于反射的一点理解(一) 设计模式--工厂方法 如何用SQLDMO在ASP.NET页面下实现数据库的备份与恢复 .NET开源项目介绍及资源推荐:数据持久层 在asp.net中如何从视频文件中抓取一桢并生成图像文件 使用AppUpdater组件(转) NHibernate初体验 <转> ASP.net的RUL重写 开发 Windows Mobile 应用程序 FAQ(转) Ajax for Java developers: Ajax with Direct Web Remoting 手机壁纸切割器源码发布
设计模式-原型模式
AnsonWu · 2007-04-05 · via 博客园 - AnsonWu

/*
 * Created by SharpDevelop.
 * User: anson.wu
 * Date: 2007-4-5
 * Time: 14:47
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 
*/
using System;namespace ClonePattern
{
    
class
 MainClass
    {
        
public static void Main(string
[] args)
        {
            ConscretePrototype1 p1
=new ConscretePrototype1("I"
);
            ConscretePrototype1 c1
=
(ConscretePrototype1)p1.Clone();
            Console.WriteLine(c1.id);
            
            ConscretePrototype2 p2
=new ConscretePrototype2("II"
);
            ConscretePrototype2 c2
=
(ConscretePrototype2)p2.Clone();
            Console.WriteLine(c2.id);
            
            Console.Read();
        }        
    }
    
public abstract class
 ProtoType
    {
        
private string
 _id;
        
public string
 id
        {
            
get{return
 _id;}
            
set{_id=
value;}
        }
        
public ProtoType(string
 id)
        {
            _id
=
id;
        }
        
public abstract
 ProtoType Clone();    
    }    
    
public class
 ConscretePrototype1:ProtoType
    {
        
public ConscretePrototype1(string id):base
(id)
        {
            
        }
        
public override
 ProtoType Clone()
        {
            
return (ProtoType)this
.MemberwiseClone();
            
        }        
    }
    
public class
 ConscretePrototype2:ProtoType
    {
        
public ConscretePrototype2(string id):base
(id)
        {
            
        }
        
public override
 ProtoType Clone()
        {
            
return (ProtoType)this
.MemberwiseClone();
            
        }        
    }
}