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 8824261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:34:04+00:00 2026-06-14T06:34:04+00:00

I am creating a graphing application that will display several graphs. The graphs will

  • 0

I am creating a graphing application that will display several graphs. The graphs will need access to some global data and some graph-specific data. For example, I want the colors consistent, so that would be global, but the specific graphs can have different grid spacing (per graph).

I created a “master object” with set defaults and a derived object with per graph configuration options

class GraphMasterObject {
  public Color gridcolor = Color.Red;
}

class GraphObject : GraphMasterObject {
  public int gridSpacing = 10;
}

Now, from my understanding, I should be able to do this

GraphObject go = new GraphObject();
Color c = go.gridColor;

How can I make it so that if I change go.gridColor, it will change across all objects that inherit from GraphMasterObject? Is this even possible? If not, what other solutions are possible? Something like

GraphMasterObject gmo = new GraphMasterObject();
gmo.gridColor = Color.Blue;

or

GraphObject go = new GraphObject();
go.gridColor = Color.Blue;
  • 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-06-14T06:34:05+00:00Added an answer on June 14, 2026 at 6:34 am

    One common approach to have a single object instance shared among many objects is the Singleton Pattern.

    http://en.wikipedia.org/wiki/Singleton_pattern

    With the Singleton Pattern, any object can request the singleton object and will be returned the same singleton object instance as any other object that requests the singleton object.

    That seems like a fine solution in your situation.

    One way in C# to implement this pattern is by using a static property, e.g.:

    public class MySingleton
    {
        static private MySingleton singleton = null;
    
        private static readonly object padlock = new object();
    
        static public MySingleton Retrieve
        {
            get
            {
                lock (padlock)
                {
                    if (singleton == null) singleton = new MySingleton(); // Initialize as needed
                }
                return singleton;
            }
        }
    }
    

    Usage

    MySingleton singleton = MySingleton.Retrieve;
    

    UPDATE

    Here’s an implementation that is superior to the one above, from the article provided by @Marksl

    public sealed class Singleton
    {
        private static readonly Lazy<Singleton> lazy =
            new Lazy<Singleton>(() => new Singleton());
    
        public static Singleton Instance { get { return lazy.Value; } }
    
        private Singleton()
        {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an C# WPF application that intake RS232 data and store all
Creating My Windows Form Application and using ADO.Net as Data Access layer and SQL
Creating an HTA that will automate the installation of several applications it starts by
Creating Facebook event for specific page with FB Graph API There is a thread
Creating a Drawable that is completely empty seems like a common need, as a
I'm creating a graph in php using the google graphing library to show StarCraft
I'm working on a graphing applications that basically graphs equations with on an HTML5
I am looking for some sort of a free JavaScript/JQuery graphing library that has
I am working on a web application that is designed to display a bunch
I am creating a graphing calculator in Java as a project for my programming

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.