code_junkie

C# - IEnumerable to delimited string

Nov 11th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. var delimitedString = selectedValues.Aggregate((x,y) => x + ", " + y);
  2.  
  3. return list.Aggregate( new StringBuilder(),
  4. ( sb, s ) =>
  5. ( sb.Length == 0 ? sb : sb.Append( ',' ) ).Append( s ) );
  6.  
  7. string.Join(", ", string[] enumerable)
  8.  
  9. var delimitedString = string.Join(",", checkboxList.Items.Where(i => i.Selected).Select(i => i.Value).ToArray());
  10.  
  11. items.Aggregate((accum, elem) => accum + ", " + elem);
  12.  
  13. StringBuilder sb = new StringBuilder();
  14. foreach(ListViewItem item in checkboxList.SelectedItems) {
  15. if(sb.Length > 0) sb.Append(',');
  16. sb.Append(item.Text);
  17. }
  18. string s = sb.ToString();
  19.  
  20. string[] toDelimit = CallSomeFunction();
  21. return toDelimit.Aggregate((x, y) => x + "," + y);
Add Comment
Please, Sign In to add comment