how to implement singelton in C# & its uses?
Answer / chandana
To implement a singleton in C#, the steps are:
1. Make the constructor private
2. Declare a static object of the same class
3. Define a static method which return the same object.
This method checks the static variable object, if it
exists, return the same, if it doesn't exist, then creates
a new instance and returns.
This is used when we want to limit the object creation to
only one object for a particular class. e.g., For a
company, we would like to limit the object of type CEO to
be only one. (that means, we know that only 1 CEO exists
for a company).
| Is This Answer Correct ? | 8 Yes | 0 No |
What is web forms in c#?
Explain partial class in c#?
What is the difference between protected and protected internal?
Can we have two main methods in c#?
What is firstordefault c#?
Why can?t you specify the accessibility modifier for methods inside the interface?
3 Answers Mind Tree, Siebel Systems,
Which are access modifiers available in c#?
When should we use delegates in c#?
What is difference between C# and VB.NET?
if we inherit class in stack so object of stack will store in stack or heap? as class a { int s; public aa(){} } stack mystack:a { } mystack obj; ans: about obj
What are All kind of access specifiers for a class and for methods
What is difference between dictionary and hashtable in c#?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)