Below is my string array :
public string[] categories { get; set; }
Now this categories contains records like below :
"categories": [
"electronic,sports",
"abc,pqr",
"xyz",
]
Input:
string[] categories = { "electronic,sports", "abc,pqr", "xyz"};
Now I want to split values in categories and create records like this but in categories variable only :
So final categories variable should contain output like below:
"categories": [
"electronic",
"sports",
"abc",
"pqr",
"xyz",
]
So I want my loop to run 5 times; if I loop on to categories variable and further lots of operation is done on this variable only so I don't want to take above final output in other variable.
foreach (var category in categories)
{
//code
}
categories = categories.SelectMany(o => o.Split(',')).ToArray();?