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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:15:39+00:00 2026-05-10T22:15:39+00:00

It is not uncommon for me (or likely anyone else) to have a list

  • 0

It is not uncommon for me (or likely anyone else) to have a list of objects I need to iterate through and then interact with a list of properties. I use a nested loop, like this:

IList<T> listOfObjects; IList<TProperty> listOfProperties;  foreach (T dataObject in listOfObjects) {     foreach (TProperty property in listOfProperties)     {         //do something clever and extremely useful here     } } 

Is this the time and performance tested pattern for this problem? Or is there something more performant, more elegant, or just plain fun (while still being readable and maintainable of course)?

The code above doesn’t make me smile. Can someone please help bring some joy to my loop?

Thank you!

Update: I use the term ‘nerd’ in a most positive sense. As part of the wikipedia definition puts it ‘that refers to a person who passionately pursues intellectual activities’. By ‘code nerd’ I mean someone who is concerned about continually improving oneself as a programmer, finding new, novel, and elegant ways of coding that are fast, maintainable, and beautiful! They rejoice to move out of VB6 and want smart people to critique their code and help them smartify themselves. (Note: they also like to make new words that end in -ify).

Final note:

Thank you to Dave R, Earwicker, and TheSoftwareJedi for sending me down the Linq path. It is just the sort of happy code I was looking for!

  • 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. 2026-05-10T22:15:40+00:00Added an answer on May 10, 2026 at 10:15 pm

    Looks like you are trying to cartesian join two lists, and apply a where clause. Here’s a simple example showing the Linq syntax for doing this, which I think is what you are looking for. list1 and list2 can be any IEnumerable, your where clause can contain more detailed logic, and in your select clause you can yank out what you need.

            var list1 = Enumerable.Range(1, 100);         var list2 = Enumerable.Range(1, 100);          foreach (var item in from a in list1                              from b in list2                              where a % b == 0                              select new { a, b })         {             Console.WriteLine(item);         }; 

    Performance will be identical to what you posted though – no desire to mislead on that respect. I do prefer this Linq syntax.

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

Sidebar

Related Questions

I have a problem that is not uncommon when building a plug-in architecture. Assembly
It's not uncommon for me to record a patch, pull it into my staging
It's not uncommon to see Python libraries that expose a universal opener function, that
It is not uncommon for our intranet web applications to link to publications, documents,
Sounds like based on Soundex or Metaphone is not uncommon option for proprietary full
Howdy all. I am trying to solve a problem which is apparently not uncommon
Here is an extract from item 56 of the book C++ Gotchas: It's not
Although it seems to be a very common issue, I did not harvest much
I have a very large C project with many separate C files and headers

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.