今年の大河は面白かった。合戦のシーンがもう少し欲しかったかな。とか、鳥取城攻めがまるっとなかったりはちょっと残念でしたが。
来年はどうかな。再来年は今から楽しみ。
internal class SelectableKeyedCollection<TKey, TItem>
: KeyedCollection<TKey, TItem>
{
private Func<TItem, TKey> keySelector;
internal SelectableKeyedCollection(Func<TItem, TKey> keySelector)
{
this.keySelector = keySelector;
}
protected override TKey GetKeyForItem(TItem item)
{
return keySelector(item);
}
}
public static class KeyedCollection
{
public static KeyedCollection<TKey, TItem>
Create<TKey, TItem>(Func<TItem, TKey> keySelector)
{
return new SelectableKeyedCollection<TKey, TItem>(keySelector);
}
}
var collection = new SelectableKeyedCollection<X, Y>(x => x.y);
var collection = KeyedCollection.Create((X x) => x.y);
static void Main(string[] args)
{
var week = KeyedCollection.Create((DateTime dt) => dt.DayOfWeek);
foreach (var n in Enumerable.Range(1, 7))
{
week.Add(DateTime.Today.AddDays(n));
}
Console.WriteLine("Today is {0:yyyy/MM/dd (ddd)}", DateTime.Today);
Console.WriteLine();
Console.WriteLine("Next 7 days...");
foreach (var d in week)
{
Console.WriteLine(d.ToShortDateString());
}
Console.WriteLine();
Console.WriteLine(
"Next Friday is {0:yyyy/MM/dd (ddd)}", week[DayOfWeek.Friday]);
}
Today is 2014/10/27 (月) Next 7 days... 2014/10/28 2014/10/29 2014/10/30 2014/10/31 2014/11/01 2014/11/02 2014/11/03 Next Friday is 2014/10/31 (金)
var invalidChars = Path.GetInvalidFileNameChars(); var converted = string.Concat( original.Select(c => invalidChars.Contains(c) ? '_' : c));
var invalidChars = Path.GetInvalidFileNameChars(); var removed = string.Concat(original.Where(c => !invalidChars.Contains(c)));