Concatenate strings inside list of strings

/ Published in: C#
Save to your folder(s)

This code demonstrates how to concatenate list of strings using lambda expression without need to use a loop.

Copy this code and paste it in your HTML
  1. List<string> someStrings = new List<string>(new string[] {"This", "will", "concatenate", "strings."});
  3. var concatenatedString = someStrings.Agregate((current, next) => string.Concat(current," ",next));
  5. Console.Write(concatenatedString);
  7. // result: This will concatenate strings.

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.