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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:11:13+00:00 2026-05-26T08:11:13+00:00

I am trying to gransp wether I can get big refactoring advantages out of

  • 0

I am trying to gransp wether I can get big refactoring advantages out of learning LINQ.
How can LINQ improve this code, which is a real-world example that is representative for a lot of code in a project I work on:

foreach (SchemeElement elem in mainDiagram.Elements)
{
    if (elem.SubType == EElemSubType.BusBar)
    {
        if (connPts.Busbars.ContainsKey(elem.ConnectionPointId))
        {
            if (!taAddrList.TAAddressList.ContainsKey(elem.Key))
            {
                taAddrList.TAAddressList.Add(elem.Key, new TAAddress());
            }

            taAddrList.TAAddressList[elem.Key] = connPts.Busbars[elem.ConnectionPointId];                        
        }
    } // if busbar
} // foreach element

For Clarity:

taAddrList.TAAddressList is of type Dictionary<ElemKey, TAAddress>
where ElemKey is a two-component type that consists of two int ID’s.

connPts.Busbars is of type Dictionary<int, TAAddress>

  • 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-26T08:11:14+00:00Added an answer on May 26, 2026 at 8:11 am

    See for yourself:

    var query = from element in mainDiagram.Elements
                where element.SubType == EElemSubType.BusBar
                where connPts.Busbars.ContainsKey(element.ConnectionPointId)
                select element;
    
    foreach (var element in query)
    {
        // by accessing immidiatly in a dictionary (assuming you are using one), you can either insert or update 
        taAddrList.TAAddressList[element.Key] = connPts.Bushbars[elem.ConnectionPointId];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to figure this out for a while, and I just can't.
I am trying to grasp a bit more of buildout with this tutorial ,
I am trying to grasp this nosql thing since it sounds good for scalability.
I'm trying to grasp the State Monad and with this purpose I wanted to
Given an example like this: class MyForm(forms.Form): name = forms.CharField() I'm trying to grasp
In trying to create better, more consistent conventions I wanted to get feedback on
i'm still trying to grasp this stuff so some help would be appreciated I
I am trying to get started with pure TDD and also consider the BDD
I am trying to get a grasp on the efficiency of neural networks over
I'm trying to do some basic opengl es programming to get started on the

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.