Created
April 29, 2022 13:59
-
-
Save ironpython2001/61d42384654f408078f18ceaf32ba866 to your computer and use it in GitHub Desktop.
C# join list of strings with delimeter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Input : [“hello”, “world”, “message”] | |
Separator: “ +++ ” | |
Result: “hello +++ world +++ message” | |
*/ | |
using System; | |
using System.Collections.Generic; | |
var input = new List<string>{"hello","world","message"}; | |
var sep = "+++"; | |
var res = string.Empty; | |
input.ForEach(x=>res = res+ x+ sep); | |
Console.WriteLine(res); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment