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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:31:29+00:00 2026-05-25T01:31:29+00:00

I have an architecture where we are passing our data nodes as IEnumerable<BaseNode> .

  • 0

I have an architecture where we are passing our data nodes as IEnumerable<BaseNode>. It all works great, but in each subclass we want to store these as List<AnotherNode> as everything in that class creates and uses AnotherNode objects (we have about 15 different subclasses).

The one place using the more strongly typed list doesn’t work is the root classes method that returns a type IEnumerable<BaseNode> and with the covariance limitations in .net 3.5, that can’t be returned. (We have to stay on .net 3.5 for now.)

But if I have List<AnotherNode> data; and return data.OfType<BaseNode>(); – that works fine. So here’s my question.

As all of data is of type BaseNode – what’s the performance hit of this call? Because the alternative is I have to cast in places which has a small performance hit – but it’s also a situation where we give up everything knowing it’s type.

  • 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-25T01:31:30+00:00Added an answer on May 25, 2026 at 1:31 am

    Two minor things:

    1. There is a small, but measurable overhead associated with yielding each item in the enumerator. If you need to care about this because you’re in a very tight inner loop, you’re actually better off iterating with a for loop on the list directly. Most likely this doesn’t matter.

    2. Because the result is IEnumerable<BaseNode> and has already been filtered through a yielding enumeration function, subsequent calls to methods like Count() or ElementAt() will not take advantage of optimizations in the LINQ implementation for Lists. This is also unlikely to be a problem unless you make frequent use of these extension methods and have a very large number of elements.

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

Sidebar

Related Questions

All the examples I've seen regarding a RESTful architecture have dealt with a single
I have a threaded console application that is working fine, but it's architecture needs
I'm on OS X 10.7 Lion and have all the dev tools installed, but
I have an architecture that reads packets from a packetized binary file, assigns each
I have 3 layer architecture. When user clicks on submit button. All the value
I have an architecture scenario and I would like to discuss to get your
I have an architecture similar to this: <div id=container> <div>stuff here</div> <div>stuff here</div> <div>stuff
I have a small architecture doubt about organizing code in separate functional units (most
Considering you have an MVVM Architecture in WPF like Josh Smith's examples How would
I am developing an application in C# WPF which will have Client-Server architecture (Client

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.