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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:40:56+00:00 2026-05-16T22:40:56+00:00

I have two lists based on the same class. I would like one list

  • 0

I have two lists based on the same class.
I would like one list to inherit the values of the other list’s class properties.

class feature {
   Guid id;
   string featureName;
   string featureType;
   .....
}

List <feature> companyFeatures;
List <feature> divisionFeatures;

The list of features is set at the company level.
When a division is created it should inherit all of the features from the company feature list. (Not copy)

If the division has a different property value in a specific feature than that of the company , the user wants to “save” this property’s value in the division’s feature list.

This gives the user the ability to add features at a later date at the company level and see these new features at the division level.

Usually there will not be many items in the division list as they are the same as the company list.

I have tried to join both lists using linq (an outer join).
It seems to fail when there is no entry for a list element at the division level.

I guess I am doing something wrong (I might not understand outer joins correctly)
Any help will be appreciated.

By the way is there a design pattern recommended for implementing inheritance.

Be happy and have a wonderful day

================================================================================

Adding an example (Hopefully this will clarify my objective)

List <feature> companyFeatures = new List <feature> 
{
    new <feature> { Guid1 , "Color" , "Text" , .... },
    new <feature> { Guid2 , "address" , "Link" , .... },
    new <feature> { Guid3 , "logo" , "Picture" , .... }
}

List <feature> divisionFeatures = new List <feature> 
{
    new <feature> { Guid2 , "address" , "text" , .... },
}

The feature list I am looking for after the “inheritance” should be:

{
    {Guid1, "Color" , "Text" , ...},
    {Guid2, "address" , "text" , ...},
    {Guid3, "logo" , "Picture" , ...}
}

Note that Guid2 now has a value of text for the type property.
Hope this clarifies.

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

    Correct me if I misunderstood. You have a Company class and a Division class and they both have a List<Feature> field? Something like…

    public class Company {
        // ...
        public List<Feature> CompanyFeatures;
        // ...
    }
    public class Division {
        public Company Company;  // The company to which the division belongs
        // ...
        public List<Feature> DivisionFeatures;
        // ...
    }
    

    If this is the case, then I would suggest to turn the feature list into a read-only property and have it automatically take care of the “inheriting”. For exapmle…

    public class Division {
        public Company Company;  // The company to which the division belongs
        // ...
        private List<Feature> _divisionFeatures;  // private now
        public IEnumerable<Feature> DivisionFeatures {
            get {
                // Take all the features for the divison...
                return _divisionFeatures.Concat(
                    // ... and add all the company features except for those that
                    // have the same name as one of the division features.
                    Company.CompanyFeatures.Where(cf => !_divisionFeatures
                        .Any(df => df.Name == cf.Name))
                );
            }
        }
        // ...
    }
    

    Alternatively, of course you can still make the List<Feature> public (so that you can still manipulate it from outside) and call the property something like DivisionFeaturesWithInheritance.

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

Sidebar

Related Questions

I have two class that inherit the same abstract base class: class base {
I have a list of items. Item is a object with two fields. One
I have two generic lists of type T. Both lists contain same type, and
In my unit test class, I am having two list. One is the expectedValue
Suppose I have two lists of type MyCustomType , a class which could be
I need help with the following problem: I have a class with two properties.
I would like to sort a list on base of multiple criteria. public class
I have two classes which both derive from the same parent: public class People{
I have two arrays of products, both formatted exactly the same, like so: $products
I have two tables that I need to compare and update values in one

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.