Skip to content

Instantly share code, notes, and snippets.

@ironpython2001
Created April 29, 2022 13:59
Show Gist options
  • Save ironpython2001/61d42384654f408078f18ceaf32ba866 to your computer and use it in GitHub Desktop.
Save ironpython2001/61d42384654f408078f18ceaf32ba866 to your computer and use it in GitHub Desktop.
C# join list of strings with delimeter
/*
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