//mysingleton using system; //singletonpage class class singletonpage { //fields protected static singletonpage checkoutpage;
//constructor is protected to ensure singleton protected singletonpage() { console.writeline("if you see this line,then the only one instence is created!"); }
//use this to create singletonpage instance public static singletonpage newcheckoutpage() { if (checkoutpage==null) checkoutpage= new singletonpage(); return checkoutpage; }
}; //-------------------------------------end of singletonpage class
//testapp class testapp { public static void main(string[] args) { console.writeline("'create' pagea:"); singletonpage pagea=singletonpage.newcheckoutpage();