How to initialize an Three-Dimensional Array String [] [] []?

Hi! How can i initialize an three dimensional array in UiPath?, i got an error when i tried to assign values

Bless!

@inf_L

strArray = new string(){}

strArray is the variable of type string

Im doing the same operation, but when i assign a value in a index, for example

Exa = new String()()() {}
Exa(0)(0)(0) = “Test”

I get the same error: “Index was out of range. Check that the collection has values and the index is less than the size of the collection”

Can you post the screenshot of the data type of above variable?

Here it is

image

is that SS from variables pane??

Thats correct!

Correct me if I’m wrong…
We don’t have a chance to create multi dimensional array in variables pane?

Can you explain how you didi that?

image

We can create multi dimensional array with the next sequence

In Variable Type select Array of (T), and now when you set array type you will select again ‘Array of (T)’ and finally select String, look

I use 2 array of T and finally a type string for create a three dimensional array

UiPath can works with bi-dimensional array, but i cant work with three-dimensional array only for assignations problems and that its what im trying to solve

1 Like

Yeah thank you @inf_L,

But what you are doing is ,

You have already initialized the string array and again you are initializing a new array to the particular index in the first initialized array. Any reason to do that?

Otherwise, if you want to insert new value to particular index of that array, you can simply do as :
image

Try to do that, UiPath will generate index error in assign

image

this is not at all an array here…

1 Like

Good point, im thinking in use C# for create the array and converts to XAML, i dont have other idea

Go with single dimensional array … it is enough to do all the required in uipath … For me till now

I need to use that array type for data management, a single dimensional array for me doesnt works :frowning:

I think I’m using a multi-dimensional array.

Here is an example from my code:
image

So for you, you could change it to 3 items rather than 5.
I used an Object Array to open it for any types, but you could probably change that to an Array of Arrays.

Then, just reference each item as you normally would using the index.

You can also look at using Dictionary (or 2/3-dimensional Dictionaries) or DataTables to manage your data. Using multi-dimensional arrays is rare for me… I used it in this instance so I could send back information from the process workflow when an exception occurs (since arguments do not maintain their value when exceptions occur, but referencing an array item in an argument does)

I dont understand very well the dictionary sctructure, but, “key” give me possibilities for create 3 dimensions?

Example: Key A, key B, key C = String[A,B,C] ?

Let’s suppose you have a 3-dimensional set of data, like this:

keyA
   keyAA
       keyAAA Value
   keyAA
       keyAAA Value
   keyAA
       keyAAA Value

keyB
   keyBB
       keyBBB Value
   keyBB
       keyBBB Value
   keyBB
       keyBBB Value

keyC
   keyCC
       keyCCC Value
   keyCC
       keyCCC Value
   keyCC
       keyCCC Value

So to reference, let’s say the Value in keyBBB in keyBB in keyB, you would use:
dict("keyB")("keyBB")("keyBBB").ToString

To set this up, you would need to declare a
Dictionary<Of String, Dictionary<Of String, Dictionary<Of String, Object> > >

Then, initialize the new dictionary in your code with an Assign while looping through each key string:

Assign dict = new Dictionary(of String, Dictionary(of String, Dictionary(of String, Object)))
For each key1 In keylist1
    Assign dict(key1) = Dictionary(of String, Dictionary(of String, Object))
    For each key2 In keylist2
       Assign dict(key1)(key2) = Dictionary(of String, Object)
       For each key3 In keylist3
           Assign dict(key1)(key2)(key3) = value

You can also change this to use a 1-dimensional or 2-dimensional dictionary if you combine all keys to the same dimension, which sometimes will be simpler to reference the values. So, that’s another thing to think about.

In the example, keylist1 keylist2 and keylist3 are the keys array which you will be using as keys for each dimension of the dictionary. And, value is obviously the value that will be stored into the third dimension.

Additionally, you can access the keys by using dict(key1)(key2).Keys, dict(key1).Keys or dict.Keys

Sorry, this was kind of challenging to explain, but essentially, you reference your dictionary just like a DataTable where the keys are strings.

Hopefully, I explained that well enough for you.

Regards.

3 Likes

Nice job! I will test my idea with that option, im trying to store data in 3 dimensions because i have 3 differentes types (ID, Months and Companies) when i get all data from an Excel i will cross information intercompanies (conciliation) but store data in 3 dimensions will help me to get faster information and easy access in execution time.