Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine(Singleton.GetInstance());
- Console.ReadLine();
- }
- }
- class Singleton
- {
- private static readonly Lazy<Singleton> lazy = new Lazy<Singleton>(()=>new Singleton());
- public string Name{get;private set;}
- private Singleton()
- {
- this.Name = System.Guid.NewGuid().ToString();
- }
- public static Singleton GetInstance()
- {
- return lazy.Value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement