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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:27:48+00:00 2026-05-11T19:27:48+00:00

I tend to use ArrayLists of structures. It is then very easy to cycle

  • 0

I tend to use ArrayLists of structures. It is then very easy to cycle through the list with a foreach.

The problem I have is I cant use a foreach to modify the structures contents and have to use a for and messy typecasts.

((dataStructure)files[x]).name = here;

Is there a tidier way to do it?

  • 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-11T19:27:48+00:00Added an answer on May 11, 2026 at 7:27 pm

    I know this sounds simplistic but just say no to mutable value types.

    They’re almost never the right solution to the problem. There are a very few exceptions, but classes are almost always the way to go.

    In addition, if you’re really using an ArrayList then you’ll be incurring an unboxing cost already… (As Konrad says, if you can use .NET 2.0 then use generics.)

    If you really insist on using mutable structures, then use a for loop instead of foreach. But please, please change to classes anyway.

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

Sidebar

Related Questions

I tend to use If Not IsDBNull(dr(data)) Then myData = dr(data) End If to
At my workplace, we tend to use iostream , string , vector , map
In new C++ code, I tend to use the C++ iostream library instead of
When debugging web sites that I'm working on, I tend to use Attach to
I was curious about how other people use the this keyword. I tend to
Is there any particular reason to use one over the other? I personally tend
I tend to use POSIX Threads , when programming in C, under Linux .
I tend to use the words define, declare and assign interchangeably but this seems
I tend to use a StatusStrip at the bottom of most of my applications
I tend to use Delphi's TStringList for text manipulation, so I write a lot

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.