netmajor
netmajor

Reputation: 6585

Axapta method return List<Array> , how to convert it in c#

I have in axapta method that return List<Array>. How can I convert it on c# side and for what ? It it possible to convert it to c# List<ArrayList> ? I see example for container:

        ArrayList magazynierzy = new ArrayList();
        for (int i = 1; i <= axContainer.Count; i++)
        {
            magazynierzy.Add(axContainer.get_Item(1).ToString());
        }

Upvotes: 1

Views: 1843

Answers (1)

Schroedingers Cat
Schroedingers Cat

Reputation: 3139

I think there are some significant flaws with this question, but taking it that you have some external process return in list of things, they are easily turned into a list of objects. You should define or identify a class that matches the items you have returned, and create a list of these. So something like:

        List<string> magazynierzy = new List<string>();
        while(axContainer.ReadNext())
            magazynierzy.Add(axContainer.get_Item(1).ToString());
        return magazynierzy;

would give you what you need ( I don't know axapta, so I have no idea how you move through the list ). If you need more complex objects, declare a class of struct for them, with a constructor that will take an axContainer object, or a list of parameters which you can pass various get_Item(n) entries into.

Upvotes: 2

Related Questions