Convert List to string with delimiter

Convert List, string. Think of a sentence. It contains some words. We could represent a sentence as a single string—one with spaces. But a list of strings (of words) is sometimes better.

var dogCsv = string.Join(",", dogs.ToArray());

var names = new List<string>() { "John", "Anna", "Monica" }; 
var result = String.Join(", ", names.ToArray());


Leave a Reply

Your email address will not be published. Required fields are marked *