How to convert a generic List to one string in C#

If you want to concatenate all items in a generic List in C# you can use the following code:


List<string> items = new List<string> { "Item 1", "Item 2", "Item 3", "Item 4" }; 


Console.Write(string.Join(Environment.NewLine, items.ToArray()));

Output
Item 1

Item 2

Item 3

Item 4

How to convert a generic List to one string in C# How to convert a generic List<string> to one string in C# Reviewed by Bhaumik Patel on 12:59 AM Rating: 5