Splitting a list<string> variable into another list<string>

Hello everyone! I have a little problem that I’m sure has a really easy fix.

I have a list of strings variable that contains names. So listNames = [Traian Basescu, Nicusor Dan, Ioan Sirbu]

I want to get 2 other lists out of this list : one that contains the Surnames ( listSurname) and another that contains Family names (listLastName).

So listSurname = [Traian, Nicusor, Ioan] and listLastName = [Basescu, Dan, Sirbu]

I know that the names in the main list can pe split by the space between the names. But I don’t know the syntax for that…

What I tried was : Assign listSurname = listNames.ToString.Split(" "c).ToList , but that doesn’t work…

Thanks in advance guys!

Hey you can use for each loop to iterate through the FullName list and create two more collection variable and add two Add To Collection activity in for each loop and pass the collection name and
Use item.Split(" “c)(0) for FirstNameCollection and item.Split(” "c)(1) for LastNameCollection


If we can rely on the space delimiting firstname / lastname

ListFirstName = listNames.Select(Function (x) x.Split(" "c).First()).toList
ListLastName = listNames.Select(Function (x) x.Split(" "c).Last()).toList

That’s awesome! It works inside a for each loop! Thanks a bunch!

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