CodShot
C# Public

Singleton Pattern in C#

Defines a singleton class with a static instance method ensuring a single object and a method returning a fixed integer.

#beadando
C#
namespace HF10
{
    internal class S : ISize
    {
        private static S instance = null;

        private S()
        {
        }

        public static S Instance()
        {
            if (instance == null)
            {
                instance = new S();
            }

            return instance;
        }

        public int Multi()
        {
            return 1;
        }
    }
}

Snippet actions

CodShot user
CodShot user
Updated: 2026-05-05 20:20
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support