Mike-Ward.Net

Pretty Printing Collections in C#

The combination of Extension Methods and LINQ can make everyday tedious programming chores a bit less annoying. Take formatting an array of strings.

static void Main()
{
    string[] languages = { "English", "German", "Portuguese", "Swedish" };
    Console.WriteLine(languages.Aggregate((n, n1) => n + ", " + n1));
}

Output:

English, German, Portuguese, Swedish

I know, it’s a little thing, but is sure is convenient. OK, your turn. What’s your favorite little extension method or LINQ snippet?

← newer older →
.Net, Technology, Life, Whatever

Recent Posts

Quick Tip - Refined GitHub
Vertical Layout for HTML Tables
Visual Studio 2017 Installer Quick Tip
VSColorOutput for VS 2017 Released
Quick ReSharper tip for inline templates
NoSQL vs. NewSQL: What's the Difference?
Exploring Mithril, A JavaScript Framework for Building Brilliant Applications
More... (1076)

Donate with PayPal