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 are major difference between classic ADO and ADO.NET? Following are some major differences among both In ADO we have recordset and in ADO.NET we have dataset. In rec

What is the AppFabric component? The AppFabric component is used to make access control and dole out messages across clouds and enterprises. It has a service-oriented architect

In which statement the LINQ query is executed? A LINQ query is executed in the For every statement in Visual Basic and in the for each statement in C#.

What is lazy initialization? Lazy initialization is a process by which an object is not initialized until it is first called in your code. The .NET 4.0 introduces a new wrapper

I need a Windows SharePoint Services or Similar Solution My company desires a reliable way of managing the documents online for each of its clients. The solution would want t

What is normalization & what are the types of normalization? Normalization is a set of rules that have been established to aid in the design of tables that are meant to be conn

How to use datagrid view

The steps that occur when we request a ASPX page are as follows:- 1) The browser sends the request to the webserver. Now  assume that the webserver at the other end is IIS. 2

How can we perform transactions in .NET? The common sequence of steps that would be performed for developing a transactional application is as follows: 1)In the first step o

Here's the General Background on our project work: We need your help building out a new application that's part of a new startup in the Silicon Valley. We've built a fairly s