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 |
Explain what are three test cases you should go through in unit testing?
Why delegates are type safe?
What are the applications of c#?
FOR EXAMPLE : CLASS Dotnet { } creating object: Dotnet dn=new Dotnet(); NOW THE QUESTION IS WHICH IS CALLED AS OBJECT ? EITHER dn OR new Dotnet() and CAN YOU PROVE YOUR ANSWER????? PLEASE REPLY...
What is sqlcommandbuilder c#?
What is the system namespace?
Can delegates be used as callbacks?
What are handlers in c#?
Why do we use void in c#?
What is dynamic dispatch?
what is an internal specifier? what happens internally when I use access specifier Internal ?
Please explain value types and reference types used in c#?