Skip to content

Instantly share code, notes, and snippets.

@yushiro
Last active Mar 4, 2019
Embed
What would you like to do?
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