Implement singleton pattern in .net, DOT NET Programming

How can we implement singleton pattern in .NET ?

The Singleton pattern basically focuses on having one and only one instance of the object running. Lets take an e.g. a windows directory service which has many entries but you can only have single instance of it throughout the network.

There are three steps needed to implement singleton pattern in .NET which is shown below:-

1)   At First create your own class with the static members.

Public class ClsStaticClass

Private shared objCustomer as clsCustomer

End class

This ensures that there is actually one and only one Customer object throughout the project.

2) Second describe a private constructor to your class.

3) Finally give a static method to get the access to your singleton object.

Posted Date: 9/22/2012 6:08:54 AM | Location : United States







Related Discussions:- Implement singleton pattern in .net, Assignment Help, Ask Question on Implement singleton pattern in .net, Get Answer, Expert's Help, Implement singleton pattern in .net Discussions

Write discussion on Implement singleton pattern in .net
Your posts are moderated
Related Questions
What I need is the following: I need an implementation in matlab under windows to open a named pipe and to read data from the pipe (an other program writes into the pipe) in quasi

What is the use of attribute  ? This attribute works as a compatibility option. We know that ASP worked in STA model and ASP.NET works in MTA model, but what if your ASP.NET

What is an identifier? Identifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must vary in spelling or casing. F

What are the methods provided by the command object? The command objects used to connect the connection object to the Datareader or the dataset. The command object provided som

We need programmers and accountants Skills required are .NET, C# Programming, Graphic Design, Commercials, Software Architecture

What is the role of the DataSet object in ADO.NET? One of the major components of ADO.NET is the DataSet object, which always remains disconnected from the database and decreas

How to Creating a Key Pair ? You can create a key pair using the Strong Name tool (Sn.exe). Key pair files usually have an .snk extension. To create a key pair At the comman

What are the advantages of DLR? The various advantages provided by DLR are: Permits you to easily execute the dynamic languages to the .NET Framework. Gives dynamic featu

to design a grid view and edit and delete the data

In search of urgent assistance with loading an ASP.net website In search of assistance with loading an ASP.net website installation onto a new server, job will start nearly D