【C#】再入門 Linq to Objects (2) どのような拡張メソッドがあるかを確認する。(2)

  • 2013.01.27 Sunday
  • 17:38
JUGEMテーマ:コンピュータ

【C#】再入門 Linq to Objects (1) どのような拡張メソッドがあるかを確認する。

上記の投稿で、System.Linq.Enumerableに定義されているpublicなメソッド名の一覧を取得してみました。しかしながらよくよく考えてみると、メソッド名だけではニュアンスぐらいしか分からず、情報不足だと感じるので、今回はシグニチャも含めて一覧にしてみたいと思います。

・・・と思ったのですが、いっぱいありすぎてブログのスペースには収まりきらなかったので、取得するために書いたコードを公開します。取得した結果は、それぞれのメソッドを見るときにでも

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
namespace ConsoleApplication29
{
    class Program
    {
        static void Main()
        {
            typeof (Enumerable)
                .GetMethods(BindingFlags.Public | BindingFlags.Static)
                .Select(DisplayTypeUtils.ConvertToVisualMethodInfo)
                .ToList()
                .ForEach(Console.WriteLine);
        }
    }
    static class DisplayTypeUtils
    {
        public static string ConvertToVisualMethodInfo(MethodInfo methodInfo)
        {
            string returnTypeName = ConvertToVisualType(methodInfo.ReturnType);
            string methodName = methodInfo.Name;
            bool isExtension = methodInfo.IsDefined(typeof(ExtensionAttribute), true);
            var methodParameters = methodInfo
                .GetParameters()
                .Select(parameterInfo => string.Format("{0} {1}",
                                                       ConvertToVisualType(parameterInfo.ParameterType),
                                                       parameterInfo.Name));
            return string.Format("{0} {1}({2}{3})",
                returnTypeName,
                methodName,
                (isExtension ? "this " : string.Empty),
                string.Join(", ", methodParameters));
        }
        static string ConvertToVisualType(Type type)
        {
            return type.IsGenericType ?
                ConvertToVisualGenericTpye(type)
                : type.Name;
        }
        static string ConvertToVisualGenericTpye(Type type)
        {
            var genericTypeArguments = type
                .GenericTypeArguments
                .Select(ConvertToVisualType);
            return string.Format("{0}<{1}>", type.Name.Split('`')[0], string.Join(", ", genericTypeArguments));
        }
    }
}

「記事の続き」機能を使えば、制限なく書けるようなので出力結果はそちらに書きます。
出力結果の件数は175件、結構あります。これにParallelも含めたりすると、約2倍より少なめ程度になるんでしょうか・・・とにかくいっぱいあります。

IEnumerable<TSource> Where(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
IEnumerable<TSource> Where(this IEnumerable<TSource> source, Func<TSource, Int32, Boolean> predicate)
IEnumerable<TResult> Select(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
IEnumerable<TResult> Select(this IEnumerable<TSource> source, Func<TSource, Int32, TResult> selector)
IEnumerable<TResult> SelectMany(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
IEnumerable<TResult> SelectMany(this IEnumerable<TSource> source, Func<TSource, Int32, IEnumerable<TResult>> selector)
IEnumerable<TResult> SelectMany(this IEnumerable<TSource> source, Func<TSource, Int32, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
IEnumerable<TResult> SelectMany(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
IEnumerable<TSource> Take(this IEnumerable<TSource> source, Int32 count)
IEnumerable<TSource> TakeWhile(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
IEnumerable<TSource> TakeWhile(this IEnumerable<TSource> source, Func<TSource, Int32, Boolean> predicate)
IEnumerable<TSource> Skip(this IEnumerable<TSource> source, Int32 count)
IEnumerable<TSource> SkipWhile(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
IEnumerable<TSource> SkipWhile(this IEnumerable<TSource> source, Func<TSource, Int32, Boolean> predicate)
IEnumerable<TResult> Join(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
IEnumerable<TResult> Join(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
IEnumerable<TResult> GroupJoin(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
IEnumerable<TResult> GroupJoin(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
IOrderedEnumerable<TSource> OrderBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
IOrderedEnumerable<TSource> OrderBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
IOrderedEnumerable<TSource> OrderByDescending(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
IOrderedEnumerable<TSource> OrderByDescending(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
IOrderedEnumerable<TSource> ThenBy(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector)
IOrderedEnumerable<TSource> ThenBy(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
IOrderedEnumerable<TSource> ThenByDescending(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector)
IOrderedEnumerable<TSource> ThenByDescending(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
IEnumerable<IGrouping<TKey, TSource>> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
IEnumerable<IGrouping<TKey, TSource>> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
IEnumerable<IGrouping<TKey, TElement>> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
IEnumerable<IGrouping<TKey, TElement>> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
IEnumerable<TResult> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
IEnumerable<TResult> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
IEnumerable<TResult> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
IEnumerable<TResult> GroupBy(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
IEnumerable<TSource> Concat(this IEnumerable<TSource> first, IEnumerable<TSource> second)
IEnumerable<TResult> Zip(this IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
IEnumerable<TSource> Distinct(this IEnumerable<TSource> source)
IEnumerable<TSource> Distinct(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
IEnumerable<TSource> Union(this IEnumerable<TSource> first, IEnumerable<TSource> second)
IEnumerable<TSource> Union(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
IEnumerable<TSource> Intersect(this IEnumerable<TSource> first, IEnumerable<TSource> second)
IEnumerable<TSource> Intersect(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
IEnumerable<TSource> Except(this IEnumerable<TSource> first, IEnumerable<TSource> second)
IEnumerable<TSource> Except(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
IEnumerable<TSource> Reverse(this IEnumerable<TSource> source)
Boolean SequenceEqual(this IEnumerable<TSource> first, IEnumerable<TSource> second)
Boolean SequenceEqual(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
IEnumerable<TSource> AsEnumerable(this IEnumerable<TSource> source)
TSource[] ToArray(this IEnumerable<TSource> source)
List<TSource> ToList(this IEnumerable<TSource> source)
Dictionary<TKey, TSource> ToDictionary(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
Dictionary<TKey, TSource> ToDictionary(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
Dictionary<TKey, TElement> ToDictionary(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
Dictionary<TKey, TElement> ToDictionary(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
ILookup<TKey, TSource> ToLookup(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
ILookup<TKey, TSource> ToLookup(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
ILookup<TKey, TElement> ToLookup(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
ILookup<TKey, TElement> ToLookup(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
IEnumerable<TSource> DefaultIfEmpty(this IEnumerable<TSource> source)
IEnumerable<TSource> DefaultIfEmpty(this IEnumerable<TSource> source, TSource defaultValue)
IEnumerable<TResult> OfType(this IEnumerable source)
IEnumerable<TResult> Cast(this IEnumerable source)
TSource First(this IEnumerable<TSource> source)
TSource First(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
TSource FirstOrDefault(this IEnumerable<TSource> source)
TSource FirstOrDefault(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
TSource Last(this IEnumerable<TSource> source)
TSource Last(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
TSource LastOrDefault(this IEnumerable<TSource> source)
TSource LastOrDefault(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
TSource Single(this IEnumerable<TSource> source)
TSource Single(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
TSource SingleOrDefault(this IEnumerable<TSource> source)
TSource SingleOrDefault(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
TSource ElementAt(this IEnumerable<TSource> source, Int32 index)
TSource ElementAtOrDefault(this IEnumerable<TSource> source, Int32 index)
IEnumerable<Int32> Range(Int32 start, Int32 count)
IEnumerable<TResult> Repeat(TResult element, Int32 count)
IEnumerable<TResult> Empty()
Boolean Any(this IEnumerable<TSource> source)
Boolean Any(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
Boolean All(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
Int32 Count(this IEnumerable<TSource> source)
Int32 Count(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
Int64 LongCount(this IEnumerable<TSource> source)
Int64 LongCount(this IEnumerable<TSource> source, Func<TSource, Boolean> predicate)
Boolean Contains(this IEnumerable<TSource> source, TSource value)
Boolean Contains(this IEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
TSource Aggregate(this IEnumerable<TSource> source, Func<TSource, TSource, TSource> func)
TAccumulate Aggregate(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
TResult Aggregate(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
Int32 Sum(this IEnumerable<Int32> source)
Nullable<Int32> Sum(this IEnumerable<Nullable<Int32>> source)
Int64 Sum(this IEnumerable<Int64> source)
Nullable<Int64> Sum(this IEnumerable<Nullable<Int64>> source)
Single Sum(this IEnumerable<Single> source)
Nullable<Single> Sum(this IEnumerable<Nullable<Single>> source)
Double Sum(this IEnumerable<Double> source)
Nullable<Double> Sum(this IEnumerable<Nullable<Double>> source)
Decimal Sum(this IEnumerable<Decimal> source)
Nullable<Decimal> Sum(this IEnumerable<Nullable<Decimal>> source)
Int32 Sum(this IEnumerable<TSource> source, Func<TSource, Int32> selector)
Nullable<Int32> Sum(this IEnumerable<TSource> source, Func<TSource, Nullable<Int32>> selector)
Int64 Sum(this IEnumerable<TSource> source, Func<TSource, Int64> selector)
Nullable<Int64> Sum(this IEnumerable<TSource> source, Func<TSource, Nullable<Int64>> selector)
Single Sum(this IEnumerable<TSource> source, Func<TSource, Single> selector)
Nullable<Single> Sum(this IEnumerable<TSource> source, Func<TSource, Nullable<Single>> selector)
Double Sum(this IEnumerable<TSource> source, Func<TSource, Double> selector)
Nullable<Double> Sum(this IEnumerable<TSource> source, Func<TSource, Nullable<Double>> selector)
Decimal Sum(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
Nullable<Decimal> Sum(this IEnumerable<TSource> source, Func<TSource, Nullable<Decimal>> selector)
Int32 Min(this IEnumerable<Int32> source)
Nullable<Int32> Min(this IEnumerable<Nullable<Int32>> source)
Int64 Min(this IEnumerable<Int64> source)
Nullable<Int64> Min(this IEnumerable<Nullable<Int64>> source)
Single Min(this IEnumerable<Single> source)
Nullable<Single> Min(this IEnumerable<Nullable<Single>> source)
Double Min(this IEnumerable<Double> source)
Nullable<Double> Min(this IEnumerable<Nullable<Double>> source)
Decimal Min(this IEnumerable<Decimal> source)
Nullable<Decimal> Min(this IEnumerable<Nullable<Decimal>> source)
TSource Min(this IEnumerable<TSource> source)
Int32 Min(this IEnumerable<TSource> source, Func<TSource, Int32> selector)
Nullable<Int32> Min(this IEnumerable<TSource> source, Func<TSource, Nullable<Int32>> selector)
Int64 Min(this IEnumerable<TSource> source, Func<TSource, Int64> selector)
Nullable<Int64> Min(this IEnumerable<TSource> source, Func<TSource, Nullable<Int64>> selector)
Single Min(this IEnumerable<TSource> source, Func<TSource, Single> selector)
Nullable<Single> Min(this IEnumerable<TSource> source, Func<TSource, Nullable<Single>> selector)
Double Min(this IEnumerable<TSource> source, Func<TSource, Double> selector)
Nullable<Double> Min(this IEnumerable<TSource> source, Func<TSource, Nullable<Double>> selector)
Decimal Min(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
Nullable<Decimal> Min(this IEnumerable<TSource> source, Func<TSource, Nullable<Decimal>> selector)
TResult Min(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
Int32 Max(this IEnumerable<Int32> source)
Nullable<Int32> Max(this IEnumerable<Nullable<Int32>> source)
Int64 Max(this IEnumerable<Int64> source)
Nullable<Int64> Max(this IEnumerable<Nullable<Int64>> source)
Double Max(this IEnumerable<Double> source)
Nullable<Double> Max(this IEnumerable<Nullable<Double>> source)
Single Max(this IEnumerable<Single> source)
Nullable<Single> Max(this IEnumerable<Nullable<Single>> source)
Decimal Max(this IEnumerable<Decimal> source)
Nullable<Decimal> Max(this IEnumerable<Nullable<Decimal>> source)
TSource Max(this IEnumerable<TSource> source)
Int32 Max(this IEnumerable<TSource> source, Func<TSource, Int32> selector)
Nullable<Int32> Max(this IEnumerable<TSource> source, Func<TSource, Nullable<Int32>> selector)
Int64 Max(this IEnumerable<TSource> source, Func<TSource, Int64> selector)
Nullable<Int64> Max(this IEnumerable<TSource> source, Func<TSource, Nullable<Int64>> selector)
Single Max(this IEnumerable<TSource> source, Func<TSource, Single> selector)
Nullable<Single> Max(this IEnumerable<TSource> source, Func<TSource, Nullable<Single>> selector)
Double Max(this IEnumerable<TSource> source, Func<TSource, Double> selector)
Nullable<Double> Max(this IEnumerable<TSource> source, Func<TSource, Nullable<Double>> selector)
Decimal Max(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
Nullable<Decimal> Max(this IEnumerable<TSource> source, Func<TSource, Nullable<Decimal>> selector)
TResult Max(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
Double Average(this IEnumerable<Int32> source)
Nullable<Double> Average(this IEnumerable<Nullable<Int32>> source)
Double Average(this IEnumerable<Int64> source)
Nullable<Double> Average(this IEnumerable<Nullable<Int64>> source)
Single Average(this IEnumerable<Single> source)
Nullable<Single> Average(this IEnumerable<Nullable<Single>> source)
Double Average(this IEnumerable<Double> source)
Nullable<Double> Average(this IEnumerable<Nullable<Double>> source)
Decimal Average(this IEnumerable<Decimal> source)
Nullable<Decimal> Average(this IEnumerable<Nullable<Decimal>> source)
Double Average(this IEnumerable<TSource> source, Func<TSource, Int32> selector)
Nullable<Double> Average(this IEnumerable<TSource> source, Func<TSource, Nullable<Int32>> selector)
Double Average(this IEnumerable<TSource> source, Func<TSource, Int64> selector)
Nullable<Double> Average(this IEnumerable<TSource> source, Func<TSource, Nullable<Int64>> selector)
Single Average(this IEnumerable<TSource> source, Func<TSource, Single> selector)
Nullable<Single> Average(this IEnumerable<TSource> source, Func<TSource, Nullable<Single>> selector)
Double Average(this IEnumerable<TSource> source, Func<TSource, Double> selector)
Nullable<Double> Average(this IEnumerable<TSource> source, Func<TSource, Nullable<Double>> selector)
Decimal Average(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
Nullable<Decimal> Average(this IEnumerable<TSource> source, Func<TSource, Nullable<Decimal>> selector)
コメント
管理者の承認待ちコメントです。
  • -
  • 2018/06/06 6:09 PM
コメントする








    
この記事のトラックバックURL
トラックバック

calendar

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930    
<< April 2019 >>

あわせて読みたい

あわせて読みたいブログパーツ

selected entries

categories

archives

recent comment

  • 【キーボード】6年前のRealForceを復活させることはできる!?その3
    art55 (05/22)
  • 【キーボード】6年前のRealForceを復活させることはできる!?その3
    分解大好き (05/18)
  • 【.NET Framework 4.5】 IListがIReadOnlyListを継承してない理由。
    art55 (02/04)
  • 【.NET Framework 4.5】 IListがIReadOnlyListを継承してない理由。
    Gen (02/04)
  • 【キーボード】RealForce が壊れて帰ってきた。
    art55 (04/29)
  • 【.NET Framework 4.5】 IListがIReadOnlyListを継承してない理由。
    art55 (02/23)
  • 【.NET Framework 4.5】 IListがIReadOnlyListを継承してない理由。
    かるあ (02/22)
  • 【C#】Dictionaryの実装・データ構造・アルゴリズムを観察する。
    art55 (01/16)
  • 【C#】Dictionaryの実装・データ構造・アルゴリズムを観察する。
    karuakun (01/16)
  • 【NetOffice】【Excel】死なないExcelプロセスをKillする。
    art55 (12/05)

recent trackback

recommend

recommend

recommend

C#プログラマのための.NETアプリケーション最適化技法 (Programmer's SELECTION)
C#プログラマのための.NETアプリケーション最適化技法 (Programmer's SELECTION) (JUGEMレビュー »)
Sasha Goldshtein,Dima Zurbalev,Ido Flatow,サシャ・ゴルドシュタイン,ディマ・ズルバレフ,イド・フラトー

recommend

ろんりと集合
ろんりと集合 (JUGEMレビュー »)
中内 伸光
とてもわかりやすいです。

recommend

recommend

シャノン・ノイマン・ディジタル世界
シャノン・ノイマン・ディジタル世界 (JUGEMレビュー »)
市川 忠男
4章がリレーショナルデータベースな内容になってます。ページ数があまりありませんが、ポイントがものすごく的確にまとまっていて、感動します。

recommend

recommend

東プレ Realforce91UBK-S 静音キーボード 静電容量無接点方式 変荷重 ブラック NG01BS
東プレ Realforce91UBK-S 静音キーボード 静電容量無接点方式 変荷重 ブラック NG01BS (JUGEMレビュー »)

テンキーレス、静音のRealForce91UBK-S。スコスコ感がたまらなく気持ちいいです。家と会社で2台持ってます。

recommend

recommend

プログラミング.NET Framework 第4版 (プログラミングシリーズ)
プログラミング.NET Framework 第4版 (プログラミングシリーズ) (JUGEMレビュー »)
Jeffrey Richter
発売予定美 2013年10月10日。.NET Frameworkとお付き合いする人のバイブルですね。

recommend

recommend

キャット・シッターの君に。
キャット・シッターの君に。 (JUGEMレビュー »)
喜多嶋 隆
私のイラストレータデビュー本です。

recommend

Essential .NET ― 共通言語ランタイムの本質
Essential .NET ― 共通言語ランタイムの本質 (JUGEMレビュー »)
ドン・ボックス,クリス・セルズ,Don Box,Chris Sells,吉松 史彰

links

profile

search this site.

others

mobile

qrcode

powered

無料ブログ作成サービス JUGEM