Vishnu K V
What is Singleton design pattern ? How to implement it ?

What is singleton design pattern ? Write a sample code for singleton implimentation ?
What is the use of it ?
Tell me a Scenario where we can use the singleton design pattern ?

By Vishnu K V in .NET on Mar 15 2020
  • Imogen Harden
    Jul, 2020 21

    public sealed class Singleton
    {
    static Singleton instance=null;
    static readonly object padlock = new object();

    1. Singleton()
    2. {
    3. }
    4. public static Singleton Instance
    5. {
    6. get
    7. {
    8. lock (padlock)
    9. {
    10. if (instance==null)
    11. {
    12. instance = new Singleton();
    13. }
    14. return instance;
    15. }
    16. }
    17. }

    }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS