Casting a TList Item
Posted on 1997-06-10
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.Strings ;
Error: Record, object, or class type required.
MyString := (MyTList.Items as TStringLIst).Strings ;
Error: Operator not applicable to this operand type.
I realize that MyTList.tems 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 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 --