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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 5, 2012, 9:23 PM EST
Please refer the below link and Our recommended articles.
http://www.codeproject.com/Articles/37897/Singleton-Design-Pattern-in-Asp-net-using-C
Thanks
Shen Hengbin94 reputationPosted Jan 5, 2012, 9:25 PM EST
http://msdn.microsoft.com/en-us/library/ff650316.aspx
VulpesRank #55 · 29.2K reputationPosted Jan 5, 2012, 11:23 PM EST
http://csharpindepth.com/Articles/General/Singleton.aspx
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 8, 2012, 6:53 PM EST
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.
AartiRank #2,383 · 594 reputationPosted Jan 9, 2012, 12:24 AM EST
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;
}
}
}