每人最多写一种,帮顶也给分。单态模式
private static singlet instance=new singlet();迭代器模式
接分来的 简单工厂...
foreach(var item in (new List<int>(){ 1 , 2 , 3 }))
{
Console.WriteLine(item);
}
路过。
class singleton
{
private singleton()
{}
public static singleton getInstance = new singleton();
}
最常用的啊~~~~~~~帮顶,LZ好人,多给点哈路过 顺便接个分 (*^__^*) 嘻嘻……
谢谢楼主纯散分的看出来了。。。纯散分的~帮顶 楼主万岁 嘿嘿、看出来了。。。纯散分的~工厂模式。路过绝代不经常来了
我就来接接分。。。。那东西三二次话就想明白难。。工厂模式
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;
}