AX – D365FO – Convert List to string (with delimited values) – strList2str

This example converts a List of string into a string delimited by comma

    public static str strList2str(List _list, str _delimiter = ', ')
    {
        ListIterator    listIterator = new ListIterator(_list);
        str             result;

        while (listIterator.more())
        {
            result += listIterator.value();

            listIterator.next();

            if (listIterator.more())
            {
                result += _delimiter;
            }
        }

        return result;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s