// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Linq; using System.Collections.Generic; namespace E { public class Program { public static List SpecialSplit20(string s) { List res = new List(); foreach(string part in s.Split(',')) { res.Add(part.Trim()); } return res; } public static List SpecialSplit35(string s) { return new List(from part in s.Split(',') select part.Trim()); } public static void Main(string[] args) { List lst20 = SpecialSplit20("New York, London ,Lisbon ,Car,C# "); foreach(string s in lst20) { Console.WriteLine("|" + s + "|"); } List lst35 = SpecialSplit35("New York, London ,Lisbon ,Car,C# "); foreach(string s in lst35) { Console.WriteLine("|" + s + "|"); } } } }