ARRAY INITIALIZATION

I CREATE AN ARRAY BUT I DON’T THIS LENGTH HOW TO INITIALIZE THIS ARRAY

@Rakesh123

arrstr = new String(3){}

If you want to create dynamic array then go for List.

System.Collections.Generic.List<System.String> - new List(Of String)

but it cannot add join pdf activity

arrstr = new String(3){} when i user this it can store only three value but i want to random data store

@Rakesh123

That’s y I suggested List. you can add ‘n’ no. of values to list.

Create one list variable and then use Add to Collection activity to add values to the list.

but hoe to add value Add to Collection and how to convert it an array

because i need dynamic array value

1 Like

Buddy @Rakesh123
here is your xaml
Main.xaml (6.5 KB)

Hope this would help you

Cheers.

It also depends on what your array will be storing. A List is useful for dynamic lengths, however, if what you are storing to this array has a static upper bound, then an Array is the correct use and not a List.

You would want to only use a List if the values you are adding to it changes throughout the job run. If the values are only set one time during the job run to process each item, then I suggest using an Array and the array will be initialized upon reading in the values that will be added.

For instance,
You have a string like “1,2,3,4,5” (which could be different each time the job runs), and you can initialize this simply by using .Split(). For example, str.Split(","c) and that gives you an array with an upper bound depending on how many items are in the string.

Another use-case would be if you are getting an array of files in a directory. For example, Directory.GetFiles(dir,"*.*").ToArray

However, if during the job run, you add files to the directory, then maybe a List would be ideal where you can use Add to Collection any time you need to add a file to your list.

So those are my thoughts. It depends on what you are trying to initialize and how the values will be used during your process.

Regards.

1 Like

thanks

Here is a detailed article on that :slight_smile: