A singleton is a class which only allows one instance of itself to be created – and gives simple, easy access to said instance. The singleton premise is a pattern across software development.
There is a C# implementation “Implementing the Singleton Pattern in C#” covering most of what you need to know – including some good advice regarding thread safety.
To be honest, It’s very rare that you need to implement a singleton – in my opinion it should be one of those things you should be aware of, even if it’s not used too often.
Related Posts:
- My C# application is returning 0xE0434352 to Windows Task Scheduler but it is not crashing
- C# Set collection?
- Why is Dictionary preferred over Hashtable in C#?
- Does anyone still use [goto] in C# and if so why?
- How does the “Using” statement translate from C# to VB?
- What is the best way to parse html in C#? [closed]
- Best C# API to create PDF
- C# cannot convert method to non delegate type
- What is the difference between const and readonly in C#?
- Pass Method as Parameter using C#
- ArrayList vs List<> in C#
- What’s the @ in front of a string in C#?
- How to solve ‘…is a ‘type’, which is not valid in the given context’? (C#)
- Calling the base constructor in C#
- Best way to repeat a character in C#
- How to empty a list in C#?
- How to open an Excel file in C#?
- What is a method group in C#?
- How do I save a stream to a file in C#?
- Print Pdf in C#
- Can a Byte[] Array be written to a file in C#?
- What is the difference between String and string in C#?
- Creating a List of Lists in C#
- C# int to byte[]
- An existing connection was forcibly closed by the remote host
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- What does a lock statement do under the hood?
- Error : Could not load file or assembly or one of it’s dependencies
- Difference between Delphi and Delphi.NET
- Get current folder path
- foreach vs someList.ForEach(){}
- Windows Application has stopped working :: Event Name CLR20r3
- Access to the path is denied
- What is the difference between ASP.NET MVC 6 and ASP.NET Core 1.0 and the reason behind the core framework?
- What does mscorlib stand for?
- WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery
- Add new item in existing array in c#.net
- Embed a System.String in XAML
- What’s the difference between struct and class in .NET?
- what is this oleaut32.dll?
- Where Is Machine.Config?
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- How to use the “Using” statement in ASP.net razor webpages?
- Reading settings from app.config or web.config in .NET
- There is no argument given that corresponds to the required formal parameter – .NET Error
- How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?
- Invalid URI: The format of the URI could not be determined
- Could not establish trust relationship for SSL/TLS secure channel — SOAP
- Cannot send a content-body with this verb-type
- Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction
- How to make an HTTP POST web request
- How to add comments into a Xaml file in WPF?
- Why did I get the compile error “Use of unassigned local variable”?
- Merge two (or more) lists into one, in C# .NET
- Cannot access a disposed object – How to fix?
- HashSet vs. List performance
- How to access Session variables and set them in javascript?
- How do you sort a dictionary by value?
- EntityType has no key defined error
- HTML.ActionLink method
- How do I restart my C# WinForm Application?
- How should I cast in VB.NET?
- Best way to reverse a string
- Warning: Found conflicts between different versions of the same dependent assembly
- Merging two arrays in .NET
- String was not recognized as a valid DateTime ” format dd/MM/yyyy”
- Connection string using Windows Authentication
- What is the purpose ApplicationDbContext Class in (under IdentityModels.cs file) ASP.NET MVC 5?
- What is The difference between ListBox and ListView
- Substring index and length must refer to a location within the string
- Cannot attach the file *.mdf as database
- Catch multiple exceptions at once?
- How to delete a file after checking whether it exists
- c# Show Windows Form
- How can I download a file with batch file without using any external tools?
- The remote server returned an error: (405) Method Not Allowed. WCF REST Service
- Produce a random number in a range using C#
- How do I concatenate two arrays in C#?
- How to play a sound in C#, .NET
- How can I delete a file that is in use by another process?
- Which passwordchar shows a black dot (•) in a winforms textbox?
- Entity Framework vs LINQ to SQL
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- How to resolve file being used by another process?
- How to properly make a http web GET request
- Strip double quotes from a string in .NET
- Convert double to float by cast or Convert.ToSingle()?
- c# .net change label text
- How to avoid a System.Runtime.InteropServices.COMException?
- Could not find any resources appropriate for the specified culture or the neutral culture
- Consider app.config remapping of assembly with no app.config mapping
- How can I generate random alphanumeric strings?
- Sequence contains more than one element
- How do you do a deep copy of an object in .NET?
- Playing a MP3 file in a WinForm application
- Best way to randomize an array with .NET
- Encrypt and decrypt a string in C#?
- Unrecognized escape sequence for path string containing backslashes
- INQ: When to use SingleOrDefault vs. FirstOrDefault() with filtering criteria
- How to set session timeout in web.config