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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:01:01+00:00 2026-05-15T01:01:01+00:00

I think i need a nudge in the right direction: I have two Tobjectlists

  • 0

I think i need a nudge in the right direction:

I have two Tobjectlists of the same datatype, and i want to concatenate these into a new list into which list1 shall be copied (unmodified) followed by list2 (in reverse)

type
  TMyListType = TobjectList<MyClass>

var
  list1, list2, resList : TMyListtype

begin
  FillListWithObjects(list1);
  FillListWithOtherObjects(list2);

  list2.reverse

  //Now, I tried to use resList.Assign(list1, list2, laOr), 
  //but Tobjectlist has no Assign-Method. I would rather not want to 
  //iterate over all objects in my lists to fill the resList
end;

Does delphi have any built-in function to merge two Tobjectlists into one?

  • 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-15T01:01:02+00:00Added an answer on May 15, 2026 at 1:01 am

    Use TObjectList.AddRange() and set OwnsObjects to False to avoid double-freeing of the items in LRes.

    var
      L1, L2, LRes: TObjectList<TPerson>;
      Item: TPerson;
    
    {...}
    
    L1 := TObjectList<TPerson>.Create();
    try
      L2 := TObjectList<TPerson>.Create();
      try
    
        LRes := TObjectList<TPerson>.Create();
        try
          L1.Add(TPerson.Create('aa', 'AA'));
          L1.Add(TPerson.Create('bb', 'BB'));
    
          L2.Add(TPerson.Create('xx', 'XX'));
          L2.Add(TPerson.Create('yy', 'YY'));
    
          L2.Reverse;
    
          LRes.OwnsObjects := False;
          LRes.AddRange(L1);
          LRes.AddRange(L2);
    
          for Item in LRes do
          begin
            OutputWriteLine(Item.FirstName + ' ' + Item.LastName);
          end;
    
        finally
          LRes.Free;
        end;
    
      finally
        L2.Free;
      end;
    
    finally
      L1.Free;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to think about performance limitations of 100 mbps ethernet (including scenarios with
I think in this case there is no need to declare a public constructor
I need to provide email sending and receiving capabilities within my java web-application. Think
I need to create a script that automatically setup a ssh tunnel. I think
I don't think this is possible, but if is then I need it :)
I think most people know how to do this via the GUI (right click
I have an existing DB2 database at my job. (At least, I think it's
I'm new to git and I have a moderately large number of weekly tarballs
What I'm looking for is a point in the right direction of helping me
I need to draw a spinning globe using opengl es in android. I think

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.