My Singleton in C#
来源:互联网 发布:淘宝童装图片 编辑:程序博客网 时间:2024/06/05 01:09
//MySingleton
using System;
//SingletonPage Class
class SingletonPage
{
//Fields
protected static SingletonPage checkoutpage;
//Constructor is protected to ensure Singleton
protected SingletonPage()
{
Console.WriteLine("if you see this line,then the only one instence is created!");
}
//Use this to Create SingletonPage instance
public static SingletonPage NewCheckOutPage()
{
if (checkoutpage==null)
checkoutpage= new SingletonPage();
return checkoutpage;
}
};
//-------------------------------------End of SingletonPage Class
//TestApp
class TestApp
{
public static void Main(string[] args)
{
Console.WriteLine("'create' pagea:");
SingletonPage pagea=SingletonPage.NewCheckOutPage();
Console.WriteLine("'create' pageb:");
SingletonPage pageb=SingletonPage.NewCheckOutPage();
Console.WriteLine("'create' pagec:");
SingletonPage pagec=SingletonPage.NewCheckOutPage();
Console.WriteLine("'create' paged:");
SingletonPage paged=SingletonPage.NewCheckOutPage();
while(true){}
}
};
- My Singleton in C#
- My Singleton in C#
- Singleton in C#
- My AbstractFactory in C#
- My Builder in C#
- My FactoryMethod in C#
- My Prototype in C#
- My Adapter in C#
- My Bridge in C#
- My Composite in C#
- My Prototype in C#
- My AbstractFactory in C#
- My FactoryMethod in C#
- Thread safe Singleton in C#
- Singleton : Implementation in Unity3d C#
- Implementing the Singleton Pattern in C#
- Implementing the Singleton Pattern in C#
- Implementing the Singleton Pattern in C#
- 用CodeDom、Reflection做一个简易计算器
- 三十岁之前不用在乎的事
- c#范型体验1
- Java连接oracle测试代码
- My Prototype in C#
- My Singleton in C#
- 101 VB.NET Applications 读书笔记(1)
- nhibernate源码分析之二:会话工厂
- 如何不使用可视化设计来显示登陆窗体?
- C#插件构架实战
- XML基础入门(一)
- Stack overflow错误的一个原因
- 用正则表达式解析C#文件(updated)
- 学习游戏开发经典网站