Hi
Can any one tell me about singleton pattern with example....................?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AartiPosted Jan 9, 2012, 5:24 AM
A singleton is a single-instance object. It is highly efficient and very graceful. Singletons have a static property that you must access to get the object reference.
Singletons preserve the conventional class approach, and don't require that you use the static keyword everywhere. They may be more demanding to implement at first, but will greatly simplify the architecture of your program. Unlike static classes, we can use singletons as parameters or objects.
Example of my C# singleton class:
using System;
namespace Example
{
public class SingletonUtility
{
private static SingletonUtility _instance;
private SingletonUtility()
{
// Caching logic here.
}
public static SingletonUtility GetInstance()
{
if (_instance == null)
_instance = new SingletonUtility();
return _instance;
}
}
}
Jignesh TrivediPosted Jan 8, 2012, 11:53 PM
please refer.
http://www.dotnetfunda.com/articles/article69.aspx
http://msdn.microsoft.com/en-us/library/ee817670.aspx
http://www.dofactory.com/Patterns/PatternSingleton.aspx
hope this help.
VulpesPosted Jan 6, 2012, 4:23 AM
http://csharpindepth.com/Articles/General/Singleton.aspx
Shen HengbinPosted Jan 6, 2012, 2:25 AM
http://msdn.microsoft.com/en-us/library/ff650316.aspx
Satyapriya NayakPosted Jan 6, 2012, 2:23 AM
Please refer the below link and Our recommended articles.
http://www.codeproject.com/Articles/37897/Singleton-Design-Pattern-in-Asp-net-using-C
Thanks