Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Casting a TList Item

Posted on 1997-06-10
1
537 Views
Last Modified: 2012-05-07
How can I cast a TList item?  I have a TList object that contains TStringLIst objects.  I want to do a find on the TSTringList, but I can't cast it.  Here are the things I have tried:

   MyString := MyTList.Items[0].Strings[0] ;
Error: Record, object, or class type required.

   MyString := (MyTList.Items[0] as TStringLIst).Strings[0] ;
Error: Operator not applicable to this operand type.

I realize that MyTList.tems[0] is actually returning a pointer, but I can't figure out how to turn that into something I can use.  I also realise that I can assign MyTList.Items[0] to a temporary variable that is typed as a TStringList, but that is a pain in the ass.  It also makes the code a lot more complicated when I am looping through a TList of TStringLIsts.

-- Clayton --
0
Comment
Question by:Clayton Neff
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 100 total points
ID: 1336928
Like this:

MyString := TStringList(MyTList.Items[0])[0];

/// John

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Strange code, can use it, but i cant figure out what it does. 3 65
How to fill array with TArray.Create? 14 93
Delphi inherited method 6 75
shape, triangle, dbctrlgrid 3 17
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question