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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:30:15+00:00 2026-06-13T15:30:15+00:00

Say I have a base class: TPart = class private FPartId: Integer; public property

  • 0

Say I have a base class:

  TPart = class
  private   
    FPartId: Integer;
  public
    property PartId: Integer read FPartId write FPartId;
  end;

and I have a generic list for this:

  TPartList = class(TObjectList<TPart>)
  public
    function IndexOfPart(PartId: Integer): Integer;
  end;

Now, if I descend from my TPart:

  TModulePart = class(TPart)
  private
    FQuantity: Integer;
  public
    property Quantity: Integer read FQuantity write FQuantity;
  end;

I want to now create a descendent of TPartList but be able to return me a TModulePart item. Doing this:

  TModulePartList = class(TPartList)
  end;

will by default think that Items property is of type TPart and not TModulePart (naturally). I don’t want to do:

  TModulePartList = class(TObjectList<TModulePart>)
  end;

because then I miss out inheriting from common methods I might have in TPartList.

Is it possible to do?

Thanks

  • 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-13T15:30:17+00:00Added an answer on June 13, 2026 at 3:30 pm

    You can do what you want like this:

    TGenericPartList<T: TPart> = class(TObjectList<T>)
    public
      function IndexOfPart(PartId: Integer): Integer;
    end;
    TPartList = TGenericPartList<TPart>;
    TModulePartList = TGenericPartList<TModule>;
    

    You can add even more flexibility if you design it like this:

    TGenericPartList<T: TPart> = class(TObjectList<T>)
    public
      function IndexOfPart(PartId: Integer): Integer;
    end;
    TPartList = TGenericPartList<TPart>;
    
    TGenericModulePartList<T: TModule> = class(TGenericPartList<T>)
      procedure DoSomething(Module: T);
    end;
    TModulePartList = TGenericModulePartList<TModule>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a couple of basic objects like so: [Serializable] public class Base
Let's say we have these two classes: public class Base { public static int
Say I have the following class: class User(Base): __tablename__ = 'users' id = Column(Integer,
Say I have a base class in Assembly A: public class MyBaseClass{ public static
Lets say I have two classes one base class: public class BaseModel { }
Say you have an abstract base class: abstract class abstractBaseClass { public abstractBaseClass(object argument);
So here is my dilemma: I have a base class (Let's say a generic
Let's say we have a base class: public abstract class BaseFragment extends Fragment {
Let's say I have a base class named BaseClass: public BaseClase{ public bool isCool;
Say I have several derived classes whose base class is a generic class. Each

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.