As mentioned above, you can use Split method to split the string. For example, if string value is "Europe, Asia, Africa":
string stringToSplit = "Europe, Asia, Africa";
string[] arrayOfString = stringToSplit.Split(',');
This overload (version) of Split method takes one argument and that is the character used to split the string. Result will be Europe, Asia and Africa. However, Asia and Africa will have one space character (' ') in the beginning because there is a space before those words in stringToSplit. So additionally, you need to trim elements of arrayOfString by adding
.Select(s => s.Trim()).ToArray()
The result would look like this:
string stringToSplit = "Europe, Asia, Africa";
string[] arrayOfString = stringToSplit.Split(',').Select(s => s.Trim()).ToArray();
stringToSplit is string you want to split using ',' character. Split(',') is the method that splits the string using ',' character and the result of that method is an array of string-s. Select(s => s.Trim()) takes each element of that array and trims it (removes all empty spaces from the beginning and from the end) and the result of it is a list of strings. s is just an alias for element, you can name it whatever you want. ToArray is a method that converts, in this case the list returned by Select(s => s.Trim()), to an array. Finally, the result stored in arrayOfString is an array containing trimmed strings.
Having in mind the result you've posted, in your example
IList<IList<Object>> values = response.Values;
if (values != null && values.Count > 0)
{
foreach (var row in values)
{
Console.WriteLine(row[0]);
}
}
values is a list of lists. In other words, each element of values (named row in the example) is a list. After you check if values exists (values != null) and if has elements (values.Count > 0), you go through each element (row) of values. Those elements are lists (IList<Object>) and you write the first element of each row by using row[0].
Definition IList<IList<Object>> values says that row is of type IList<Object>, which means that every element of row is of type Object. Method WriteLine has an overload (version) that accepts an argument of type Object as it is in this case. That argument is then implicitly (in the background) converted to type string.
Looking at the output, there's no doubt that those element of type Object are actually strings, otherwise it will write name of the type, or some other data not useful, or not readable.
There are two possibilities.
Either list values contains one element (one list of objects, row) and the first element of row is a string (it is definitely of type string) that contains all those names separated by Environment.NewLine, or list values contains multiple elements (lists of objects, row-s) and the first element of each row is a string that contains single name.
If you know that you accept one string and need to separate it, than ok, and it would be the first possibility. In that case you could try
row[0].ToString().Split('\n')
However, it seems like the other case, where there are multiple lists of objects and the first one is name. In that case you don't need to split anything.
rowdefined, and how isrow[0]filled?IList<Object>is rarely useful. Show us whatresponse.Valuescontains from your debugger, not from a screenshot.