C#

C#のforeach内で現在のループ回数を知る

C#

こちらで紹介されていたのを、自分でも書いてみました。 http://mag.autumn.org/Content.modf?id=20100726164321 http://blogs.wankuma.com/rti/archive/2010/07/27/191691.aspx http://d.hatena.ne.jp/okazuki/20100728/1280300415 foreachの中で現在のルー…

前後の要素同士でペアを作って反復処理

C#

コレクションの前後の要素同士でペアを作って反復処理するメソッドを、拡張メソッドで実装してみました。 using System; using System.Collections.Generic; static class EnumerableExtension { public static void ForEachPair<T>(this IEnumerable<T> collectio</t></t>…

コレクションの要素を一意にする

C#で、コレクションの要素を一意にする処理(C++のstd::unique)をしたく、.NETのBCLに用意されていないかと探していました。 System.Linq.Distinct がそれにあたるようです。