Often programmers want to convert an array into one string with for example comma delimited.
Traditionally, in C#, it can be achieved by

int[] array = {1,2,3};
string delimited = string.Join(”,”, array);
Console.WriteLine(delimited ) // output: "1,2,3"
 

However, string.Join does not apply to any generic IEnumerable object. It would so much easier if this method behavior could be applied [...]

Continue reading about Separator Delimited ToString for Array, List, Dictionary, Generic IEnumerable

admin on February 14th, 2008

Simple script to combine elements within nested list (A list’s elements are lists)

static void Main(string[] args)
{
  // initialize a list object with List<string> elements
  List<List<string>> nestedList = new List<List<string>>();
  // add an element to the main list object
  nestedList.Add(new List() { “a”, “b”, “c” });
  // add another element to the main list object 
  [...]

Continue reading about LINQ: Combine elements in nested collection