Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6161331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:27:37+00:00 2026-05-23T21:27:37+00:00

Possible Duplicate: Difference between static class and singleton pattern? we use static class for

  • 0

Possible Duplicate:
Difference between static class and singleton pattern?

we use static class for common operation. the same thing can be done singleton class also

here i am giving two class one is static class and one is singleton class. actually things is getting harder for me that when one should go for static class and when we should go for singleton class.

public sealed class SiteStructure
{
    /// <summary>
    /// This is an expensive resource we need to only store in one place.
    /// </summary>
    object[] _data = new object[10];

    /// <summary>
    /// Allocate ourselves. We have a private constructor, so no one else can.
    /// </summary>
    static readonly SiteStructure _instance = new SiteStructure();

    /// <summary>
    /// Access SiteStructure.Instance to get the singleton object.
    /// Then call methods on that instance.
    /// </summary>
    public static SiteStructure Instance
    {
    get { return _instance; }
    }

    /// <summary>
    /// This is a private constructor, meaning no outsiders have access.
    /// </summary>
    private SiteStructure()
    {
    // Initialize members, etc. here.
    }
}

static public class SiteStatic
{
    /// <summary>
    /// The data must be a static member in this example.
    /// </summary>
    static object[] _data = new object[10];

    /// <summary>
    /// C# doesn't define when this constructor is run, but it will likely
    /// be run right before it is used.
    /// </summary>
    static SiteStatic()
    {
    // Initialize all of our static members.
    }
}

please explain when one need to create static class and when singleton class. thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:27:38+00:00Added an answer on May 23, 2026 at 9:27 pm

    My opinion is:

    Static class you need to create a class which will operate to you like API base, so basically it’s just functions or constants set. For the user of your class it’s being static signals about the lack of the state, basically.

    Singleton is just a class whom instance can be only one, and the case that you provide static property and private default constructor (cause that what you should do for not letting to your class user create objects) it’s just consiquence of design.

    Hope this helps.

    Regards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Difference between static class and singleton pattern? I'm thinking about the choice
Possible Duplicate: Difference between static class and singleton pattern? Which is better in Java,
Possible Duplicate: What's the difference between an abstract class and a static one? Hello
Possible Duplicate: What is the difference between "typename" and "class" template parameters? When defining
Possible Duplicate: Difference between i++ and ++i in a loop? Can anyone explain what's
Possible Duplicate: PHP: What is the difference between an interface and abstract class? As
Possible Duplicate: Difference between ref and out parameters in .NET When to use ref
Possible Duplicate: What is the difference between Class.this and this in Java I know
Possible Duplicate: private final static attribute vs private final attribute What's the difference between
Possible Duplicate: What's the difference between NOT EXISTS vs. NOT IN vs. LEFT JOIN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.