Posted By

Neven on 12/16/11


Tagged

list strings concatenate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ovuncgursoy


Concatenate strings inside list of strings


 / Published in: C#
 

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

  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
Posted By: saviolan on February 2, 2012

More on C# string operations

http://csharp.net-informations.com/string/csharpstringtutorial.htm

savs.

You need to login to post a comment.