Design Pattern 8-Singleton

xiaoxiao2021-03-06  63

Using system;

Namespace pattern {///

/// summary description for class1. /// public class singleton {private static singleleton singleton singleton singleton singleton singleton singleton singleton singleton } Public static singleleton getinstance () {if (son == null) SON = new singleleton (); return SON;}}} // single piece // Singleton S1 = Singleton.GetInstance (); // console.writeline S1.GETHASHCODE (). TOSTRING ()); // Singleton S2 = Singleton.GetInstance (); // console.writeline (S2.GETHASHCODE (). toString ()); /// Customer Cus1 = New Customer () ; // console.writeline (Cus1.getHashcode (). TOSTRING ()); // Customer Cus2 = New Customer (); // console.writeline (Cus2.gethashcode (). Tostring ()); // // (S1.Equals (S2)) Console.WriteLine ("S1 == S2"); // // IF (Cus1.equals (CUS2)) Console.Writeline ("CUS2 == Cus2");

转载请注明原文地址:https://www.9cbs.com/read-113100.html

New Post(0)