Skip to content

Instantly share code, notes, and snippets.

@yushiro
Last active March 4, 2019 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yushiro/3a4bbbd838c5c3e8da0958a706424dd5 to your computer and use it in GitHub Desktop.
Save yushiro/3a4bbbd838c5c3e8da0958a706424dd5 to your computer and use it in GitHub Desktop.
c#单件模式代码 #C#
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