Reputation: 2620
I am using a C# application to do some work and send back the results in AX via a service.
I've created a few classes in AX and use their instances in C# then I send the objects back with the help of a classic array.
In AX I receive the stuff in a System.Collections.ArrayList
and here comes my question:
How can I iterate over this collection and check the objects type?
for (...)
{
if (arr[i] is SalesLineCSharp)
{
}
else if (arr[i] is SalesTableCSharp)
{
}
//etc....
}
Something like is
or as
?
I've just made an example and tried this ..
info(strFmt("%1", classId2Name(classIdGet(arr.get_Item(i)))));
Indeed for the custom types I get the name of the class and for strings and ints I get CLRObject, but that looks so bad.
Is there a cleaner way to accomplish this?
Upvotes: 3
Views: 5741