mardi 13 novembre 2018

Singleton patterns

Good day, I have 2 classes Singleton and Program, help make it so that I enter the string values 2 times, and they do not have to repeat At the end, bring out Console.WriteLine(); //dublicate || no dublicate

class Main

using System; namespace DZ4_1 { class Program { static void Main(string[] args) { Singelton s1 = Singelton.Initiallize(Console.ReadLine(), Console.ReadLine()); Console.WriteLine(); Console.ReadKey(); } } }

Class Singleton

using System; using System.Collections.Generic; using System.Text;

namespace DZ4_1 { public class Singelton { private static Singelton single = null; protected Singelton() {

    }
    public static Singelton Initiallize(string a, string b)
    {
        if (single == null)
            single = new Singelton();
        return single;
    }
}

}

Aucun commentaire:

Enregistrer un commentaire