Iterating through 2 IEnumerable objects

I’ve opened 2 different spreadsheets and used “read column” on both to create 2 ienumerable object variables and called them SnServers and SWindResults. I’m using a For Each loop to iterate through SnServers to determine if the values in SnServers also exist in SWResults. I’ve created a variable called “SnowServerName” and assigned it the value of currentItem.ToString.

In my if statement I have the following condition: SWindResults.Contains(SnowServerName), and the results being recorded contains a lot of lower case values because of different syntax being used in the different spreadsheets. I want to change all values in both ienumerable objects to lowercase to receive accurate results. I know I can change “SnowServerName” to currentItem.ToString.ToLower, so my question is, How do i change all of the values in SWindResults to lowercase to make sure I have a perfect match? Hope this is making since. Below is a screenshot of my logic:

If you want to just use it in the If clause, you could do

SWindResults.Select(Function(x) x.ToLower).Contains(SnowServerName)

getting this error:


Not sure what enumerables are those …the below works for any…I am assuming to be array of string…so instead of using loop and condition you can use intersect which gives all the common values

requiredarray = a1.Select(function(x) x.ToString.ToLower).Intersect(a2.Select(function(x) x.ToString.ToLower))

To print you can use log message with String.Join(",",requiredarray)


i was able to use the below assign statement to change to all lower case:

SWindResults = SWindResults.Cast(of string)().Select(Function(item)item.ToLower()).toList()

and then able to use my original conditional statement of SWindResults.Contains(SnowServerName) and the automation worked as expected.

1 Like

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