Dynamic array

Hi Community,

I have an dynamic array like this below:
Number of items in this array can change as this is getting created by a string var which do not a fix length. String could be anything (For eg: Its me again, Hi there how are you etc)
As per my requirement, I need to to first five to six items from the array if array size is bigger than that. I am using array index to concatenate like this:
Var1=Arr1(0)+" "+Arr1(1)
I am having a concern that via this way Var1 creation is not dynamic since it could be possible to run out of index. For Eg: If array had only 1 item then Var1 assign would fail.
Please suggest some way to make this thing more dynamic.

Thank you!

Hi @Akshat_Sharma1 - How about checking the array count and then concat

Ex: ArrayVar is your variable name, take if condition


>> concat

>> Skip Concat


Can you try the following expression?

String.Join(" ",Arr1.Take(5))


Hi @Akshat_Sharma1

Another approach

If(array1.Count > 5, String.Join(" ", array1.Take(6)), String.Join(" ", array1))


Thank you so much @Yoichi
This is exactly what i wanted. Thats great!
Thank you so much

1 Like

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