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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:14:36+00:00 2026-06-04T00:14:36+00:00

I have need to store multiple values in list or array for a moment.

  • 0

I have need to store multiple values in list or array for a moment. These values are multiple types like string, int, datetime etc.

I have two options:

Options 1:

Declare an array with type of object like this:

object[] values;

Option 2:

Declare array for interface and implement own classes for each type to hold.

interface IType
{
}

IType[] values;

class StringValue : IType
{
    public string StringValue { get; set; }  // not declared in interface!
}

class IntValue : IType
{
    public int IntValue { get; set; }  // not declared in interface!
}

Question:

What are performance benefit and/or impact for each implementation options? As far as I know (or quessing), boxinq has own performance impact when using object[].

What about option two? At least using StringValue or IntValue property needs more code, first type must be determined, IType must be casted to StringValue or IntValue etc…

Is there so big impact to performance using object[] that I really should think about something like options 2?

  • 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-04T00:14:38+00:00Added an answer on June 4, 2026 at 12:14 am

    The class IntValue you propose essentially boxes an integer… it encapsulates it in an object to that it can participate in an object[]. I would expect no performance improvement with that scenario, and depending on your implementation, it could be worse than compiler-implemented boxing.

    Having said that, I agree with the commenters that your efforts are probably better focused improving other areas of your code. There are very few scenarios where the boxing overhead will be the most important area of attention.

    I did encounter a scenario (working with many numbers that could be int, float, or double) where the boxing mattered to user experience. I solved that using expression trees.

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

Sidebar

Related Questions

I have a need to store an ordered list of strings and am trying
I have id values for products that I need store. Right now they are
I have small class called 'Call' and I need to store these calls into
I have values that are 64-bit unsigned ints, and I need to store them
I have a score i need to calculate for multiple items for multiple users.
I am developing a geneology application, and I have a need to store dates
I have a program in which I need to store a Class object into
I have a use case where I only need to store certain fields to
Did you ever have the following situation: you need to store information, but a
I have some things in my app that I need to store, in order

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.