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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:59:30+00:00 2026-06-03T03:59:30+00:00

This is non-language-specific, but I’ll use examples in C# . Often I face the

  • 0

This is non-language-specific, but I’ll use examples in C#. Often I face the problem in which I need to add a parameter to an object inside any given iteration of at least one of its parameters, and I have always to come up with a lame temporary list or array of some kind concomitant with the problem of keeping it properly correlated.

So, please bear with me on the examples below:

  • Is there an easier and better way to do this in C sharp?

    List<String> storeStr;
    
    void AssignStringListWithNewUniqueStr (List<String> aList) {
        foreach (String str in aList) {
            storeStr.add(str);
            str = AProcedureToGenerateNewUniqueStr();
        }
    }
    
    void PrintStringListWithNewUniqueStr (List<String> aList) {
        int i = 0;
        foreach (String str in aList) {
            print(str + storeStr[i]);
            i++;
        }
    }
    

Notice the correlation above is guaranteed only because I’m iterating through an unchanged aList. When asking about a “easier and better way” I mean it should also make sure the storeStr would always be correlated with its equivalent on aList while keeping it as short and simple as possible. The List could also have been any kind of array or object.


  • Is there any language in which something like this is possible? It must give same results than above.

    IterationBound<String> storeStr;
    
    void AssignStringListWithNewUniqueStr (List<String> aList) {
        foreach (String str in aList) {
            storeStr = str;
            str = AProcedureToGenerateNewUniqueStr();
        }
    }
    
    void PrintStringListWithNewUniqueStr (List<String> aList) {
        foreach (String str in aList) {
            print(str + storeStr);
        }
    }
    

In this case, the fictitious “IterationBound” kind would guarantee the correlation between the list and the new parameter (in a way, just like Garbage Collectors guarantee allocs). It would somehow notice it was created inside an iteration and associate itself with that specific index (no matter if the syntax there would be uglier, of course). Then, when its called back again in another iteration and it was already created or stored in that specific index, it would retrieve this specific value of that iteration.

  • 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-03T03:59:30+00:00Added an answer on June 3, 2026 at 3:59 am

    Why not simply project your enumerable into a new form?

    var combination = aList
          .Select(x => new { Initial = x, Addition = AProcedureToGenerateNewUniqueStr() })
          .ToList()
          .ForEach(x =>
               { 
                   print(x.Initial + x.Addition);
               });
    

    This way you keep each element associated with the new data.

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

Sidebar

Related Questions

This likely applies to non MVC too. But, Is it possible to use the
This question might seem very specific but I am in need of some ideas
Note: This is a general programming question, not specific to any language, but feel
This is actually a non-critical question, but I get this warning most of the
This is probably a stupid question, but what exactly is a non-blocking web server?
I'm not sure if this is possible (complete non-flash developer speaking), but we have
I have some triples that look like this: test:thing rdfs:label Non-Language Label test:thing rdfs:label
I wrote a parser for a non-trivial language this weekend. Some of the output
Note This is not a REBOL-specific question. You can answer it in any language.
I need to create an iPhone/Mac app that is in a non-English language only.

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.