C # Singleton's implementation.

xiaoxiao2021-03-06  50

Public Class Singleton

{

PRIVATE Static Bool Instance_flag = FALSE

Private singleton () // Change the Singleton function to private to prevent it from calling New to create it.

{

Console.writeline ("You can only see me once");

}

Public Static Singleton getInstance ()

{

IF (! installation_flag)

{

INSTANCE_FLAG = true;

Return new startleton ();

}

Else Return NULL;

}

}

}

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

New Post(0)