Skip to content

Instantly share code, notes, and snippets.

@rohinomiya
Last active March 21, 2017 03:31
Show Gist options
  • Save rohinomiya/3144900 to your computer and use it in GitHub Desktop.
Save rohinomiya/3144900 to your computer and use it in GitHub Desktop.
C# で シングルトンパターン ref: http://qiita.com/rohinomiya/items/6bca22211d1bddf581c4
using System;
namespace SampleLog4Net
{
/// <summary>
/// Description of ClassNullLogger.
/// </summary>
public sealed class ClassNullLogger
{
private static ClassNullLogger instance = new ClassNullLogger();
public static ClassNullLogger Instance {
get {
return instance;
}
}
private ClassNullLogger()
{
}
}
}
// Singletonパターン
public sealed class SingletonClass
{
private static SingletonClass _singleInstance = new SingletonClass();
public static SingletonClass GetInstance()
{
return _singleInstance;
}
private SingletonClass()
{
//TODO: initialization
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment