Last active
March 4, 2019 09:15
-
-
Save yushiro/3a4bbbd838c5c3e8da0958a706424dd5 to your computer and use it in GitHub Desktop.
c#单件模式代码 #C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace DesignPatterns | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Singleton singleton = Singleton.Instance; | |
} | |
} | |
class Singleton | |
{ | |
private static readonly Singleton instance = new Singleton(); | |
private Singleton() | |
{ | |
} | |
public static Singleton Instance | |
{ | |
get | |
{ | |
return instance; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment