You are probably better off enumerating the TList directly when adding to the custom array - creating an Object[] array is an unnecessary step, at least in your example.
Something like (untested):
Anyway, if you know the target type before runtime, you should probably not use reflection, but have a specific function for each type you need to use.
Something like (untested):
Function ListToArrayOf:Object(list:TList, of:TTypeId) Local arrayType:TTypeId = of.ArrayType() Local result:Object = arrayType.NewArray( list.Count() ) Local idx:Int = 0 For Local obj:Object = EachIn list arrayType.SetArrayElement result, idx, obj Next Return result End Function
Anyway, if you know the target type before runtime, you should probably not use reflection, but have a specific function for each type you need to use.