Remove an object from an array of string

studio
variable

#1

how to remove a string from an array of string[]


#2

@abdel
If you want to delete the element based on value then use

Array_Variable.Remove(“element”)

If you want delete based on index then use
Array_Variable.RemoveAt(index)

Regards,
Mahesh


#3

there is no remove methode for arrays


#4

You can convert it to list using array.toList, then it will have the given methods but effectively that should affect your array

Also this can be achieved using linq so you can using inside an assign (other method are subs and require to use either invoke code or invoke method

strArray = strArray.Where(Function(s) s = “toberemove”).ToArray

Cheers


#5

i had used text2.ToList.RemoveAt(0)

but it say that value does not reproduce a value


#6

Go for the second approach i provided - As said this require to use either invoke method/Code and would only work if you have a list initially.

You cannot remove items from an array, you can only reassign it to a new one.

Cheers


#7

there is a message:


#8

You need to select the type of the list with the dropdown

image

Cheers


#9

I agree with @Florent_Salendres’s solution. You can just basically filter your array to remove the item.
But I think he meant <>, not =

Assign activity: strArray = strArray.Where(Function(s) s <> “toberemove”).ToArray

So you only pull in all items that don’t equal the string.


#10

Indeed :slight_smile: