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
Prepare datamodel, API and more Project Description: Dear all, we would like you to prepare database and an API which can be used in the shopping cart (checkout and delivery

how do I load txt file into listbox

What is the role of the JIT compiler in .NET Framework? The JIT compiler is an significant element of CLR, which loads MSIL on target machines for execution. The MSIL is stored

Question 1 Discuss the following with respect to .NET Technologies Web Applications Web Server Connections Question 2 Write a sample program using ASP.NET explain

Explain the XML elements. The elements are the central units of an XML document that define and identify data. The elements are represented by the tags. You can also make your

How can you implement a condition in a workflow? You can implement a condition by using either of the following ways: By creating a rule condition - Specifies that you can e

Project Description: I require a custom texture painting plug-in for the latest version of Unity 3D. The project can have features that are common in Photoshop and Mari for pain

inheritance real time examples

A few changes to OutloProject Description: We require someone who is familiar with programming plug-in to work with Microsoft Outlook. Initially we just require a simple chan

MAT LAB programming Project Description: i have simulation and i need to simulate the equation in ,and test the all simulation it working with your work program other code sh