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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:23:20+00:00 2026-06-12T14:23:20+00:00

I have a class in C# that is storing information on a stack to

  • 0

I have a class in C# that is storing information on a stack to be used by other pieces of the application later. The information is currently stored in a class (without any methods) and consists of some ints, shorts, floats and a couple of boolean values.
I can be processing 10-40 of these packets every second – potentially more – and the information on the stack will be removed when it’s needed by another part of the program; however this isn’t guaranteed to occur at any definite interval. The information also has a chance of being incomplete (I’m processing packets from a network connection).
Currently I have this represented as such:

public class PackInfo
{
    public boolean active;
    public float f1;
    public float f2;
    public int i1;
    public int i2;
    public int i3;
    public int i4;
    public short s1;
    public short s2;
}

Is there a better way that this information can be represented? There’s no chance of the stack getting too large (most of the information will be cleared if it starts getting too big) but I’m worried that there will be a needless amount of memory overhead involved in creating so many instances of the class to act as little more than a container for this information. Even though this is neither a computationally complex or memory-consuming task, I don’t see it scaling well should it become either.

  • 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-12T14:23:21+00:00Added an answer on June 12, 2026 at 2:23 pm

    This sounds like it would be a good idea to use a generic Queue for storing these. I have the assumption that you’re handling these “messages” in order.

    As for the overhead of instantiating these classes, I don’t think that instantiating 10-40 per second would have any visible impact on performance, the actual processing you do afterwards would likely be a much better candidate for optimization than the cost of instantiation.

    Also, I would recommend only optimizing when you can actually measure performance in your application, otherwise you might be wasting your time doing premature optimization.

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

Sidebar

Related Questions

We currently have a utilities class that handles a lot of string formatting, date
I have a c# class that has 20+ string properties. I set about a
Say I have a class that looks like this (get/set omited): class InfoClass{ String
Assume I have a class that looks like this: class Sample { public string
I have a class that has an Action<string> called DisplayData ; In various points
I have a static util class that does some string manipulation on a bit
I have a Version class that contains a version_number string, and can obtain a
I have a class called: ComplexNumber and I have a string that I need
I have a class, called DateField , that has a string Value property. If
I have 3 types, (TCPClient, string, class) Note that the class is defined at

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.