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

  • Home
  • SEARCH
  • 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 238911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:32:36+00:00 2026-05-11T20:32:36+00:00

Does anyone have any suggestions as to how to go about designing a container

  • 0

Does anyone have any suggestions as to how to go about designing a container class, in C#, that has upwards of thirty variables contained within it?

I have written it out as a set of variables, as there are a few different types, e.g. string or DateTime, however I am thinking that it would perhaps be better to house them all in a dictionary of objects with their property names as keys?

  • 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-11T20:32:36+00:00Added an answer on May 11, 2026 at 8:32 pm

    If all the fields are required, then they are required. Using a dictionary can only add overhead and incur extra memory costs. A dictionary approach may be useful in a few specific scenarios, such as property bag implementations, and sparse event handlers (since events are the most obvious sparse data).

    If the fields are used sparsely (i.e. often not more than a few are in use), then perhaps push the related fields into a number of inner classes (per group of related fields) – i.e. instead of:

    class Foo {
        string userName;
        int userId;
    
        string orderReference;
        DateTime orderDate;
    
        ...
    }
    

    something like:

    class Foo {
         class UserInfo { // move this outside if it makes sense to re-use it
              public int Name {get;set;}
              public int Id {get;set;}
         }
         UserInfo user;
    
         class OrderInfo { // move this outside if it makes sense to re-use it
             public string Reference {get;set;}
             public string Date {get;set;}
         }
         OrderInfo order;
    }
    

    Then when you have to store the user data, create a new UserInfo; if you don’t need the user data, leave user null.

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

Sidebar

Related Questions

Does anyone have any suggestions about where I can find a C# implementation for
Does anyone have any suggestions on how I can take a DataSet that I
Does anyone have any suggestions about problems I could give to my students as
Does anyone have any suggestions about how to schedule the creation of reports and
Does anyone have any practical suggestions about how to manage feature creep in GUIs?
Does anyone have any suggestions on how to edit an <a href=''> link in
Does anyone have any tips that could help speed up a process of breaking
Does anyone have any useful advice/links to information about working with mp3 files in
Does anyone have any good references for designing and implementing an idea I have
Does anyone have any suggestions for creating meta tables in a database? These tables

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.