StringBuilder sb = new StringBuilder();
List <string>
list.add("one");
list.add("two");
list.add("three");
You could do the following loop:
foreach(var item in list){
sb.Append(item);
}
An alternative method to achieve the same functionality would go like this:
list.ForEach(item =>sb.Append(item));
With this method you save 2 lines of code and improve readability.
No comments:
Post a Comment