I want to create a function that takes a list of strings as a parameter, joins them together into a single string with each element separated by a comma, and returns the result. For example, if the array [“asdf”, “jkl”, “zxc”]
is passed into the function, it will return a string “asdf, jkl, zxc”
.
In C#, my function signature look like this:
string MySolution(string[] inputStrings)
{
List<string> cities = new List<string>();
cities.Add("New York");
cities.Add("Mumbai");
cities.Add("Berlin");
cities.Add("Istanbul");
string line = string.Join(",", cities.ToArray());
Console.WriteLine(line);
}
--I'm just having problems when it comes to having a user input where in a user will enter values, not the static as shown in the code. I will appreciate any suggestions or answers with regards to that. This also reserves as a test in the company that I'm applying for.