My Singleton in C #

zhaozj2021-02-16  131

// mysingletonusing system; // singletonpage classclass singletonpage {// fields protected static singletonpage checkoutpage;

// Constructor is protected to ensure singleton protected singletonpage ("if you see line, the only one thing inscious!");}

// use this to create singletonpage instance public static singleletonpage newcheckoutpage () {if (checkoutpage == null) checkoutpage = new singletonpage (); return checkoutpage;}

}; // ----------------------------------- End of SingletonPage Class

// TestAppClass TestApp {public static void main (string [] args) {console.writeline ("'Create' Pagea:"); SingletonPage Pagea = SingletonPage.NewCheckoutPage ();

Console.WriteLine ( " 'create' pageb:"); SingletonPage pageb = SingletonPage.NewCheckOutPage (); Console.WriteLine ( " 'create' pagec:"); SingletonPage pagec = SingletonPage.NewCheckOutPage (); Console.WriteLine ( " ' Create 'Paged: "); SingletonPage Paged = SingletonPage.NewcheckoutPage ();

While (TRUE) {}}};

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

New Post(0)