每人最多写一种,帮顶也给分。
------解决方案--------------------
看出来了。。。纯散分的~
------解决方案--------------------
呵呵 飘过 接分
------解决方案--------------------
我就来接接分。。。。那东西三二次话就想明白难。。
------解决方案--------------------
工厂模式。路过绝代不经常来了
------解决方案--------------------
class singleton
{
private singleton()
{}
public static singleton getInstance = new singleton();
}
最常用的啊~~~~~~~
------解决方案--------------------
帮顶 楼主万岁 嘿嘿、
------解决方案--------------------
接分来的
------解决方案--------------------
看出来了。。。纯散分的~
------解决方案--------------------
帮顶,LZ好人,多给点哈
------解决方案--------------------
纯散分的
------解决方案--------------------
路过 顺便接个分 (*^__^*) 嘻嘻……
谢谢楼主
------解决方案--------------------
迭代器模式
foreach(var item in (new List<int>(){ 1 , 2 , 3 }))
{
Console.WriteLine(item);
}
------解决方案--------------------
简单工厂...
路过。
------解决方案--------------------
简单抽象工厂
------解决方案--------------------
工厂模式
public class DaoFactory {
private static UserDao userDao = null;
private static DaoFactory instance = new DaoFactory();
private DaoFactory() {
try {
Properties prop = new Properties();
InputStream inStream = DaoFactory.class.getClassLoader()
.getResourceAsStream("daoconfig.properties");
prop.load(inStream);
String userDaoClass = prop.getProperty("userDaoClass");
Class clazz = Class.forName(userDaoClass);
userDao = (UserDao) clazz.newInstance();
} catch (Throwable e) {
throw new ExceptionInInitializerError(e);
}
}
public static DaoFactory getInstance() {
return instance;
}
public UserDao getUserDao() {
return userDao;
}
}
------解决方案--------------------
观察者模式
public class Button
{
public event EventHandler Click;
}
------解决方案--------------------
单态模式
private static singlet instance=new singlet();
public static singlet getinstance{
return instance;}
------解决方案--------------------
可以给我们讲一下这些模式么?
哈哈!
------解决方案--------------------
命令模式:
// Command pattern -- Structural example
using System;
// "Command"
abstract class Command
{
// Fields
protected Receiver receiver;
// Constructors
public Command( Receiver receiver )
{
this.receiver = receiver;
}
// Methods
abstract public void Execute();
}
// "ConcreteCommand"
class ConcreteCommand : Command
{
// Constructors
public ConcreteCommand( Receiver receiver ) :
base ( receiver ) {}
// Methods
public override void Execute()
{
receiver.Action();
}
}
// "Receiver"
class Receiver
{
// Methods
public void Action()
{
Console.WriteLine("Called Receiver.Action()");
}
}
// "Invoker"
class Invoker
{
// Fields
private Command command;
// Methods
public void SetCommand( Command command )
{
this.command = command;
}
public void ExecuteCommand()
{
command.Execute();
}
}
//// <summary>
/// Client test
/// </summary>
public class Client
{
public static void Main( string[] args )
{
// Create receiver, command, and invoker
Receiver r = new Receiver();
Command c = new ConcreteCommand( r );