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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:06:13+00:00 2026-06-18T11:06:13+00:00

I am wanting to store key – value data and be able to access

  • 0

I am wanting to store key – value data and be able to access it in an efficient manner.

Basically: I have a custom object(EquipmentObj) and w/ in that object is a property called “DeviceType”. In the constructor of the object, I am passing a string which goes out to a Dictionary (Local Variable of EquipmentObj) and returns a value if the Dictionary has the key.

In an attempt to minimize initializing the Dictionary 25 times on the heap, (EquipmentObj is instantiated 25-50 times) I am wondering if there is a more efficient way to do this.

My first thought was XML, but I can’t add deserialization; I wont get into this.

My next thought was possibly using a static class. But I still need to define the KeyValuePair or Dictionary and static classes cant have instance members.

What would you all suggest?

Here is a sample of what I am basically doing right now.

class EquipmentObj
    {
        public EquipmentObj(string deviceType)
        {
            addItems(); 
            this.DeviceType = EquipmentList.ContainsKey(device_Type) ? EquipmentList[deviceType] : "Default";
        }
        public string DeviceType { get; set; }
        private Dictionary<string, string> EquipmentList = new Dictionary<string, string>();

        private void addItems()
        {
            //Add items to Dictionary 
        }
    }
  • 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-18T11:06:15+00:00Added an answer on June 18, 2026 at 11:06 am

    A static class can’t have instance members, but a non-static class can have static members. You can make EquipmentList and addItems() both static without changing EquipmentObj itself.

    class EquipmentObj
    {
        public EquipmentObj(string deviceType)
        {
            addItems(); 
            this.DeviceType = EquipmentList.ContainsKey(device_Type) ? EquipmentList[deviceType] : "Default";
        }
        public string DeviceType { get; set; }
        private static Dictionary<string, string> EquipmentList = new Dictionary<string, string>();
    
        public static void addItems()
        {
            //Add items to Dictionary 
        }
    }
    

    You’d call it as:

    EquipmentObj.addItems();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to store some data that is essentially just an array of key-value
I have 3 json requests which fetch data, i am wanting to store the
Given a basic key/value array, I'm wanting to store two sorted arrays based on
I am wanting to generate and store a CRC (or similar) value for a
I'm wanting to store a wide array of categorical data in MySQL database tables.
I seem to often find myself wanting to store data of more than one
I'm wanting to store some contact information and allow the user to call/email the
I'm wanting a more secure way to store high scores and power ups like
I am having an application where I have to send several small data per
Currently we store our address data like so: string suiteNumber (ie. unit number) string

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.