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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:27:36+00:00 2026-06-17T09:27:36+00:00

I’m migrating a legacy Delphi application to Delphi-XE2, and I’m wondering if there’s a

  • 0

I’m migrating a legacy Delphi application to Delphi-XE2, and I’m wondering if there’s a good reason to replace the arrays defined as Array of MyType to TArray<MyType>. So the question is what are the pros and cons of TArray<T> usage instead of Array of MyType?

  • 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-17T09:27:36+00:00Added an answer on June 17, 2026 at 9:27 am

    The main advantage is less onerous type identity rules. Consider:

    a: array of Integer;
    b: array of Integer;
    

    These two variables are not assignment compatible. It is a compiler error to write:

    a := b;
    

    On the other hand if you use the generic syntax:

    a: TArray<Integer>;
    b: TArray<Integer>;
    

    then these two variables are assignment compatible.

    Sure, you can write

    type
      TIntegerArray = array of Integer;
    

    But all parties need to agree on the same type. It’s fine if all code is in your control, but when using code from a variety of sources, the advent of generic dynamic arrays makes a huge difference.

    The other advantage that springs to mind, in similar vein, is that you can readily use the generic array type as the return type of a generic method.

    Without the generic array you are compelled to declare a type of this form:

    TArrayOfT = array of T
    

    in your generic class, which is rather messy. And if you are writing a generic method in a non-generic class, then you’ve no way to make that declaration. Again the generic array solves the problem.

    TMyClass = class
      class function Foo<T>: TArray<T>; static;
    end;
    

    This all follows on from type compatibility rules described in the documentation like this:

    Type Compatibility

    Two non-instantiated generics are considered assignment
    compatible only if they are identical or are aliases to a
    common type.

    Two instantiated generics are considered assignment
    compatible if the base types are identical (or are aliases to a
    common type) and the type arguments are identical.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am confused How to use looping for Json response Array in another Array.
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.