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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:49:50+00:00 2026-05-25T05:49:50+00:00

I have read a lot about the danger of using structures as a data

  • 0

I have read a lot about the danger of using structures as a data type, I wonder if there is any problem with this one,

List<Summarized> SummarizedList = new List<Summarized>();
    Summarized SumInfo;
    struct Summarized
    {
        public string sBrand;
        public string sModel;
        public string sCustomer;
        public int sline;
        public string sLeader;            
        public int sDesire;
        public int sReal;               
    } 

As you can see I use a generic list of items type SumInfo which is the struct data type. whenever I need to update an item of the list I just do the following:

SumInfo = (Summarized)SummarizedList[CurrentPos];
            SumInfo.sDesire = DesireProd;
            SumInfo.sReal = RealProduced;                
            SummarizedList[CurrentPos] = SumInfo;

where CurrentPos is the position of the item I want to update.

Everything works fine so far, so could be any problem with that in the future? Is this struct one of the mutable ones?

Thanks.

  • 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-25T05:49:50+00:00Added an answer on May 25, 2026 at 5:49 am

    Everything works fine so far, so could be any problem with that in the future? Is this struct one of the mutable ones?

    Yes, it’s a mutable struct. Yes, it will work.

    However, I would argue that this struct should be a class. For details as to why, refer to Choosing Between Classes and Structures. In this case, you’re violating 3 of the cases which should always be true for structs:

    • It logically represents a single value, similar to primitive types (integer, double, and so on).
    • It has an instance size smaller than 16 bytes.
    • It is immutable.

    This would strongly suggest a class is more appropriate for your type. It would also simplify your code.


    BTW – Side note, the cast is not required in your code above. You should be able to just write:

    SumInfo = SummarizedList[CurrentPos];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read a lot about this issue but mine still seems to be
This should be something simple, I have read a lot about the organization browser
I have read a lot about unit testing, but I still haven't found any
I have read really a lot of posts about this topic, however nothing works
I have read a lot about this! But I can't make a clear idea!
I have read a lot about mocking, particularly using Rhino Mocks and have learned
Recently I have read a lot about different NoSQL databases and how they are
I have heard a lot about anti patterns and would like to read a
I have read a lot of articles on developing classes (I am using php),
I have read a lot about the Java class loading process lately. Often I

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.