Jogi
Jogi

Reputation: 1

Add Multiple items of a List to one line in another List

Imagine I've this following List:

List<string> thirdList = new List<string> {"0","0","56'BCD"}

I need to add all of its items to a new list as one value i.e., "0 0 56'BCD. Please note that there is space between the items in the new string. Thanks in advance.

Upvotes: 0

Views: 4196

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460038

So you want a list with a single string? You can use String.Join:

var result = new List<string>{ String.Join(" ", thirdList) };

Upvotes: 13

Related Questions