Check if element exist in array



I need to check if a certain element or value exist in a predefined array. How could this be done in a If statement?

I need to use If Statement because I have to do something based on the result.


use Array_Variable.Contains(“Element_Variable”) in if activity

it will return true if array contains the value other wise it will return false.




If i need to keep all in a for each row DataTable activity (check 2500 lines) could i then write:

Array_Variable.Contains(“Element_Variable”) = True

And then go to either Then or Else in the If Statements?


You just mention this in if activity

then add the steps what you want to do if in case it is true, and in else if it’s false.

Let us take an array of strings Array A and we want to check whether strb is present in Array A.

Then in if condition we have to mention Array A.Contains(strb).



@MAHESH1 how to get index of element with using loops in an array?


Hi @Manjuts90,

For example

 string[] array = new string[6];
        array[0] = null;
        array[1] = "carrot";
        array[2] = "rat";
        array[3] = "Sample";
        array[4] = "carrot";
        array[5] = "apple";

        int index2 = Array.IndexOf(array, "banana");

If you get -1 value you value not exists in the array.
index2 -> index of the array



@arivu96 i want with out using loop and i didn’t find indexOf option for array in uipath. Do you know any method


Hi @Manjuts90,

I am able to get the index value
Array.IndexOf(arrayvariable, "yourvalue")



@arivu96 i am not getting that option in uipath