Compiler error encountered processing expression with Concat

I’m doing a basic training exercise from the UiPath Academy. I want to add a string to an array. I got the error below when I typed Ax.Concat(item).ToArray. I understand what I need to do to fix it (add {} around the word item), but could someone explain in simple terms why the {} are required around the word ‘item’? The error message didn’t help me to understand why this is incorrect.

The concat method concatenates 2 objects of the same type. As an example, if you used string1.Concat(string2) where both string1 and string2 are of type string, all’s good. In your case Ax is an array so you need to pass to the Ax.Concat method another array. If you pass ‘item’ to it, which is a string, it throws the error, but if you add the {}, it’s no longer a string, it’s an array containing only the string from the item variable.

Hope this is clear enough, if not ask and I shall try again:))


Thanks! Makes perfect sense.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.