/ Published in: C#
This is useful for handling user provided, comma separated data. For example, in the case where the user inputs " 1, 2,3,4,, 5, 6, " you would want to remove the whitespace around each item as well as the empty items to produce "1,2,3,4,5,6".
Expand |
Embed | Plain Text
items.RemoveAll(delegate(string s){return s.Trim() == "";}); items.ForEach(delegate(string s) { items[items.IndexOf(s)] = s.Trim(); }); Console.WriteLine(String.Join(",",items.ToArray())); Console.ReadKey();
You need to login to post a comment.
