Category Archives: Other

C# : To return a comma delimited list from an array or collection of strings

Don’t:

            var description = new StringBuilder("");
            foreach (var item in productItems.Where(x => x.ItemType == type))
            {
                description.Append(item.Description + ", ");
            }
            return description.Remove(description.Length - 2, 2).ToString();

Do:

return string.Join(", ", productItems.Where(x => x.ItemType == type).Select(x => x.Description).ToArray());

because the first example fails when your collection has no elements.

Sherlock Holmes … the Death and Life

A one man show by Roger llewellyn is possibly the most impressive one man show you’ll see anytime soon. Half a dozen characters interact and by the interval you face the puzzle of how exactly the relationship between Arthur Conan Doyle and his creations can work out. And whereas this kind of frame-breaking has been with us for a long time, this is the first time I’ve seen it done convincingly.