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

推荐订阅源

有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
博客园 - 【当耐特】
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
B
Blog RSS Feed
腾讯CDC
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
DataBreaches.Net
The Cloudflare Blog
V
V2EX
S
SegmentFault 最新的问题

博客园 - 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: 10:55
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 
*/
using System;namespace Structural
{
    
class
 MainClass
    {
        
public static void Main(string
[] args)
        {
            Product[] product
=new Product[2
];
            product[
0]=new
 CreatorA().FactoryMethod();
            product[
1]=new
 CreatorB().FactoryMethod();            
            Console.Read();
        }
    }
    
//
    public abstract  class
 Product
    {
    
    }
    
public class
 ProductA:Product
    {
        
public
 ProductA()
        {
            Console.WriteLine(
"ProductA Been Create"
);
        }
    }
    
public class
 ProductB:Product
    {
        
public
 ProductB()
        {
            Console.WriteLine(
"ProductB Been Create"
);
        }
    }
    
public abstract class
 Creator
    {
        
public abstract
 Product FactoryMethod();
        
    }
    
public class
 CreatorA:Creator
    {
        
public override
 Product FactoryMethod()
        {
            
return new
 ProductA();
        }
    }
    
public class
 CreatorB:Creator
    {
        
public override
 Product FactoryMethod()
        {
            
return new
 ProductB();
        }
    }
}