How to split a string, in a List of strings?

Hi, I have a string called - “Name1,Dish1;Name2,Dish2;Name3,Dish3”.

First I created an array of strings by splitting this in “;” (Semicolon). So it’ll be {“Name1,Dish1”, “Name2,Dish2”, “Name3,Dish3”}.

Now, I’m looping through this and trying to split the first string in the array i.e. Name1,Dish1. But the split function is giving me an error when I try to assign it to a string. I’m getting the Error -
Value of type ‘1-dimensional array of String’ cannot be converted to ‘String’.

If I use Item.ToString then instead of the Item, System.String[] is getting printed. I couldn’t seem to split this and print. Please help.

(Actual Process - I need to loop through the array - {“Name1,Dish1”, “Name2,Dish2”, “Name3,Dish3”} and check if Name is existing on the screen, if yes then I have to print the corresponding Dish.
If Name1 is present, print Dish1)

You can try like the below expression @manojj.yadav


Hi @manojj.yadav

If u want to check only the name
Ucan use this function inside the foreach activity



So can get the name of the item.


1 Like

It is Printing Name1,Dish1. But how do I split this string further ?Using Split function is still giving me System.Stringh[] as output.

Screenshot 2022-10-27 201642



Output -> Name1

Output -> Dish


1 Like

we can split the string on ; and also split later on , for getting returned a list(Of String())

mySplitList = yourStringVar.split(";“c).select(Function (x) x.Split(”,"c)).ToList
then we can access name/dish like
mySplitList(0)(0) for name and mySplitList(0)(1) for dish

As an alternate we can also create a dictionary as long the names are unique


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