CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Text.RegularExpressions;
public class record
{
public int flashid { get; set; }
public int position {get; set; }
public string value { get; set; }
}
public class Program
{
public static void Main()
{
var list = new List<record>
{
new record{ flashid = 450, position = 5, value = "a"},
new record{ flashid = 450, position = 6, value = "b"},
new record{ flashid = 450, position = 7, value = "c"},
new record{ flashid = 450, position = 7, value = "d"},
new record{ flashid = 450, position = 7, value = "e"},
new record{ flashid = 450, position = 8, value = "f"},
new record{ flashid = 450, position = 9, value = "g"}
};
var extendedList = Enumerable
.Range(1, 10)
.GroupJoin(list, n => n, r => r.position, (n, g) => g
.DefaultIfEmpty(new record { flashid = 450, position = n, value = "." }));
var result = extendedList
.Aggregate(Enumerable.Repeat("", 1), (a, c) => a
.SelectMany(b => c
.Select(d => b + d.value)));
foreach (var r in result)
{
Console.WriteLine(r);
}
}
}