using System;
using System.Linq;
public class Test
{
public static void Main()
{
var listOfGroups = new[] { "a1", "a2", "b1" }
.GroupBy(x => x.Substring(0, 1))
.ToList();
var newGroup = new[] { "foo", "bar" }.GroupBy(x => "baz").Single();
listOfGroups.Add(newGroup);
foreach (var group in listOfGroups)
{
Console.WriteLine(group.Key + ":");
Console.WriteLine(" " + string.Join(", ", group));
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKCnB1YmxpYyBjbGFzcyBUZXN0CnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCQl2YXIgbGlzdE9mR3JvdXBzID0gbmV3W10geyAiYTEiLCAiYTIiLCAiYjEiIH0KCQkgICAgICAgICAgICAgICAgICAgICAgIC5Hcm91cEJ5KHggPT4geC5TdWJzdHJpbmcoMCwgMSkpCgkJICAgICAgICAgICAgICAgICAgICAgICAuVG9MaXN0KCk7CgkJCgkJdmFyIG5ld0dyb3VwID0gbmV3W10geyAiZm9vIiwgImJhciIgfS5Hcm91cEJ5KHggPT4gImJheiIpLlNpbmdsZSgpOwoJCQoJCWxpc3RPZkdyb3Vwcy5BZGQobmV3R3JvdXApOwoJCQoJCWZvcmVhY2ggKHZhciBncm91cCBpbiBsaXN0T2ZHcm91cHMpCgkJewoJCQlDb25zb2xlLldyaXRlTGluZShncm91cC5LZXkgKyAiOiIpOwoJCQlDb25zb2xlLldyaXRlTGluZSgiICAgICIgKyBzdHJpbmcuSm9pbigiLCAiLCBncm91cCkpOwoJCX0KCX0KfQ==