C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
9
Reply
What is a singleton?
Md. Raskinur Rashid
10y
1.7k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
A singleton is a design pattern used when only one instance of an object is created and shared; that is, it only allows one instance of itself to be created. Any attempt to create another instance simply returns a reference to the first one. Singleton classes are created by defining all class constructors as private. In addition, a private static member is created as the same type of the class, along with a public static member that returns an instance of the class. Here is a basic example:public class SingletonExample {private static SingletonExample _Instance;private SingletonExample () { }public static SingletonExample GetInstance() {if (_Instance == null) {_Instance = new SingletonExample ();}return _Instance;} }
Md. Raskinur Rashid
10y
4
Refer http://dotnetmagic.blogspot.in/
Rajesh Singh
10y
0
http://www.c-sharpcorner.com/code/1990/what-is-singleton-design-pattern.aspx
Rajesh Singh
10y
0
This is helpful http://www.dotnetperls.com/singleton
Hashim Shafiq
10y
0
Singleton is a design pattern that restricts the instantiation of a class to one object. We are achieving this through a static instance variable & private constructor. This is useful when exactly one object is needed to coordinate actions across the system.
Sujeet Suman
10y
0
single ton is a mechanism in which we can create a single instance(object) of class and this obj is used as a reference when we required another object of class
Rahul Prajapat
10y
0
single ton is a mechanism in which we can create a single instance(object) of class and this obj is used as a reference when we required another object of class
Pankaj Kumar Choudhary
10y
0
http://www.dotnetperls.com/singleton
Munesh Sharma
10y
0
singleton is a class which we can create only one instance.
Nitu S
10y
0
Message