Demo entry 6637103

doublel

   

Submitted by ad on Aug 30, 2017 at 10:28
Language: C#. Code size: 414 Bytes.

    public class Singleton  
    {  
        //定义一个静态变量来保存类的实例  
    private static Singleton uniqueInstance;  
    //定义私有构造函数,使外界不能创建该类实例  
    private Singleton(){}  
    //定义公有方法提供一个全局访问点  
    public static Singleton GetInstance()  
    {  
        if (uniqueInstance == null)  
    {  
       uniqueInstance = new Singleton();  
    }  
    return uniqueInstance;  
         }  
    }  

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).