Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Singletone
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine(Singleton.GetInstance().SecretPassword);
- Console.WriteLine(Singleton.GetInstance().SecretPassword);
- Console.ReadKey();
- }
- }
- public class Singleton
- {
- private static Singleton Instance = new Singleton();
- private Random _random = new Random();
- public int SecretPassword { get; private set; }
- private Singleton()
- {
- SecretPassword = _random.Next(10000, 100000);
- }
- public static Singleton GetInstance()
- {
- return Instance;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement