i have a class in my project and i want it to initiate only once with passing specific parameter via constructor , but when i pass different parameter it should initiate.how i can achieve this with singleton design pattern. or suggest me any other design pattern if this couldn't achieve with singleton .
class Program
{
static void Main()
{
SiteStructure s = SiteStructure.Instance;
}
}
public sealed class SiteStructure
{
static readonly SiteStructure _instance = new SiteStructure();
public static SiteStructure Instance
{
get
{
return _instance;
}
}
SiteStructure()
{
// Initialize.
}
}
Aucun commentaire:
Enregistrer un commentaire