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)
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