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
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.