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 |
If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?
What is asp net c#?
Differentiate between the public and private ?
What are the fundamental oop concepts?
What is an inheritance in c#?
What is private constructor c#?
What is the purpose of dependency injection?
What is lazy keyword in c#?
Why do we use stringbuilder in c#?
What are bitwise logical operators?
Are structs value types c#?
What does a constructor do 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)