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."});
  2.  
  3. var concatenatedString = someStrings.Agregate((current, next) => string.Concat(current," ",next));
  4.  
  5. Console.Write(concatenatedString);
  6.  
  7. // result: This will concatenate strings.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.