Question: Which of the following code samples will create a comma separated list from IList<string> or IEnumerable<string>?
A
B
C
D
ublic static T[] ToArray(IEnumerable<T> source) {
return new List<T>(source).ToArray();
}
IEnumerable<string> strings = ...;
string[] array = Helpers.ToArray(strings);
string joined = string.Join(",", strings.ToArray());
string joined = string.Join(",", new List<string>(strings).ToArray());
B
List<string> ls = new List<string>();
ls.Add("one"); ls.Add("two");
string type = string.Join(",", ls.ToArray());
C
string commaSeparatedList = input.Aggregate((a, x) => a + ", " + x)
D
public static string Join(this IEnumerable<string> source, string separator) {
return string.Join(separator, source);
}
Note: Not available