How to access specific index of an array?

I need to access the 1st index of array and add it to a dictionary.

Hi @Aishwarya_Maggi

I think you can access the element by this

string firstElement = yourArray(0).ToString

This would give you the first element, then you can use Add To Dictionary activity to add

Thanks,
Prankur

3 Likes

I get the error message the index was outside the bounds of your array

error

Please verify that there is some value on Index 1, error means there is no value where you are trying to get. Can you attach a sample what are you trying to achieve?

See this sample

Main.xaml (6.5 KB)

Thanks,
Prankur

2 Likes

Hey, thank so much for helping!

So Iā€™m splitting a string and adding the split string to an array. When trying to access a specific index I get the following error

error
Main.xaml (15.3 KB)
project.json (633 Bytes)

1 Like

Hi,

Before printing specific value from the array, use for each and print all the items, and check if array(1) contains any value, we get this error when the item in the array is null.

Before accessing the array element, check length of the array. To access an element, your element index should be less than the array length.
if(elementIndex < myArray.Length)

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