I have a scenario where i have list of string which is having 4 strings , like {“AU-0001”, “AU-0002”, “AU-0003”,“AU-0004”}.based on some condition i have to remove the elements from the list. If condition satisfies for all the list elements i have to delete that element from list. currently i am using invoke method with method as RemoveAt by passing the index. so whenever each element matches the condition it is getting removed and list is getting modified by reducing one count each time when condition matches. I am doing this in for each list items.When it comes to last element removal i am getting error like list index outside the bounds of array. Can someone let me know what approach i can follow for this?.
Please take a look at this approach. You can create a list of strings, let’s say listA, which basically is a superset. Then upon iteration & conditions application, you can move the strings to another list, let’s say listB, which are supposed to be deleted. Now you have a listA which contains all the strings & listB which contains the strings that has to be deleted. Then you can use the following expression to basically exclude the listB from listA: