Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

singleton design pattern c# volatile

public sealed class Singleton
{
   private static volatile Singleton instance;
   private static object syncRoot = new Object();

   private Singleton() {}

   public static Singleton Instance
   {
      get 
      {
         if (instance == null) 
         {
            lock (syncRoot) 
            {
               if (instance == null) 
                  instance = new Singleton();
            }
         }

         return instance;
      }
   }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: sequelize top 
Csharp :: tostring format 2 decimals 
Csharp :: ? operator 
Csharp :: remove item from list in for loop c# 
Csharp :: C# unit test exception using attribrute 
Csharp :: compare two strings in c# 
Csharp :: migrationbuilder insert data example 
Csharp :: Failed to generate swagger file. Error dotnet swagger tofile --serializeasv2 --output 
Csharp :: unity agent look at 
Csharp :: c# how to append in array 
Csharp :: and operator in c# 
Csharp :: c# obsolete class 
Csharp :: HTTP Error 500.35 - ASP.NET Core does not support multiple apps in the same app pool 
Csharp :: print pdf in c# 
Csharp :: c# list remove by index 
Csharp :: onmousedown not working unity 
Csharp :: label wpf 
Csharp :: csharp bubble sort 
Csharp :: how to change color of part from the text in textblock wpf 
Csharp :: unity auto scroll 
Csharp :: unity dropdown 
Csharp :: asp c# page scroll position change after postback 
Csharp :: C# traverseall elements in class property 
Csharp :: top down view movement script 
Csharp :: unity color alpha not working 
Csharp :: c# split quotation 
Csharp :: Ignore case string linq c# 
Csharp :: declare multiple variables in for loop C# 
Csharp :: example of List c# 
Csharp :: c# byte + byte is int 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =