Append string to array pt2

Okay, I feel silly for asking this because it seems so basic, but I was trying to append another string to an arrary of strings like in this other post: Append string to array
And it’s not working! Everyone said it worked for them, but I made a new array of strings, threw some animal names in there, and then tried to use .Concat like @ClaytonM said to do. I’m getting the error message below, which I know tells me that the variable types are different, so this method doesn’t work. What am I missing?

Concat error


Hi @Joe.Matuch

  1. Use Assign Activity
    LHS : StringD → Array of String (Variable)
    RHS : {“Cat”,“Dog”}

  2. Use Assign Activity
    LHS : ArrHorse → Array of String (Variable)
    RHS : {“Horse”}

  3. Use Assign Activity
    LHS : Output → System.Collection.Generic.IEnumerable<System.String> (Variable)
    RHS : StringD.Concat(ArrHorse)

  4. Message Box
    Output(2)
    Refer to the screenshot

Hope it will help you

Regards
Gokul

arr3 = arr1.Concat(arr2).toArray

Thanks, @Gokul001 . That helps me understand what part I had wrong. I am relatively new to coding (~1 year). Is the difference that an array has a fixed length whereas an IEnumerable can be any length?

Thanks, @ppr ! That’s helpful, too. So, when we use .Concat on an array, it turns the array into an IEnumerable, and we need to turn it back into an array?

arrays are not forseen for such a dynamic task. The list datatype is to prefer, when adding / removing items.

The result of a concat is the Enumerable(Of XXX)

As Mentioned above with the toArray, toList method we can get it back to the datatype we want to get

grafik
grafik

2 Likes

Yes @Joe.Matuch array has an fixed length and IEnumerable has any length.

you can declare the Array length as New String(1) {"Germania","Franta" }

Regards
Gokul

2 Likes

Thanks to you both for helping me understand this more.

1 Like

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