How to initialize a dynamic 1-dimensional array of strings

Hello Forum!

I want to put some information that I am reading off an Excel Workbook into a 1-dimensional array of strings.

How do I initialize this array as a Dynamic 1-dimensional array of strings.

I have tried using the New List(Of String()) method but I get the following error: “ERROR Compiler error(s) encountered processing expression “New list(of String())”.
Value of type ‘System.Collections.Generic.List(Of String())’ cannot be converted to ‘1-dimensional array of String’.”

Kind regards,
Kam.

can you show the screenshot

Hi @KamKam,

basically Array is of fixed size, when you say dynamic array then you can use List which is a collection which allows adding and removing items from the collection.
So to initialize the list use —> New List(Of String) variable type should be
List<String> (System.Collections.Generic.List<System.String>) As shown in below shot.

I did try lists initially but I couldn’t figure out how to add values to them in UiPath.

How would I do that?

@KamKam
You can simply use add to collection activity.

OR

If you want to add values while initializing then use

New List(Of String)({"first","second"})

2 Likes

Thank you.

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