英語で読む

次の方法で共有


IEnumerable<T> インターフェイス

定義

列挙子を公開します。この列挙子は、指定した型のコレクションに対する単純な反復処理をサポートします。

C#
public interface IEnumerable<out T> : System.Collections.IEnumerable
C#
public interface IEnumerable<T> : System.Collections.IEnumerable

型パラメーター

T

列挙するオブジェクトの型。

この型パラメーターは共変です。 つまり、指定した型、または強い派生型のいずれかを使用することができます。 共変性および反変性の詳細については、「ジェネリックの共変性と反変性」をご覧ください。
派生
実装

次の例では、IEnumerable<T> インターフェイスを実装する方法と、その実装を使用して LINQ クエリを作成する方法を示します。 IEnumerable<T>を実装する場合は、IEnumerator<T> も実装する必要があります。C# の場合のみ、yield キーワードを使用できます。 IEnumerator<T> を実装するには、IDisposable も実装する必要があります。この例で説明します。

C#
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class App
{
    // Exercise the Iterator and show that it's more
    // performant.
    public static void Main()
    {
        TestStreamReaderEnumerable();
        Console.WriteLine("---");
        TestReadingFile();
    }

    public static void TestStreamReaderEnumerable()
    {
        // Check the memory before the iterator is used.
        long memoryBefore = GC.GetTotalMemory(true);
      IEnumerable<String> stringsFound;
        // Open a file with the StreamReaderEnumerable and check for a string.
      try {
         stringsFound =
               from line in new StreamReaderEnumerable(@"c:\temp\tempFile.txt")
               where line.Contains("string to search for")
               select line;
         Console.WriteLine("Found: " + stringsFound.Count());
      }
      catch (FileNotFoundException) {
         Console.WriteLine(@"This example requires a file named C:\temp\tempFile.txt.");
         return;
      }

        // Check the memory after the iterator and output it to the console.
        long memoryAfter = GC.GetTotalMemory(false);
        Console.WriteLine("Memory Used With Iterator = \t"
            + string.Format(((memoryAfter - memoryBefore) / 1000).ToString(), "n") + "kb");
    }

    public static void TestReadingFile()
    {
        long memoryBefore = GC.GetTotalMemory(true);
      StreamReader sr;
      try {
         sr = File.OpenText("c:\\temp\\tempFile.txt");
      }
      catch (FileNotFoundException) {
         Console.WriteLine(@"This example requires a file named C:\temp\tempFile.txt.");
         return;
      }

        // Add the file contents to a generic list of strings.
        List<string> fileContents = new List<string>();
        while (!sr.EndOfStream) {
            fileContents.Add(sr.ReadLine());
        }

        // Check for the string.
        var stringsFound =
            from line in fileContents
            where line.Contains("string to search for")
            select line;

        sr.Close();
        Console.WriteLine("Found: " + stringsFound.Count());

        // Check the memory after when the iterator is not used, and output it to the console.
        long memoryAfter = GC.GetTotalMemory(false);
        Console.WriteLine("Memory Used Without Iterator = \t" +
            string.Format(((memoryAfter - memoryBefore) / 1000).ToString(), "n") + "kb");
    }
}

// A custom class that implements IEnumerable(T). When you implement IEnumerable(T),
// you must also implement IEnumerable and IEnumerator(T).
public class StreamReaderEnumerable : IEnumerable<string>
{
    private string _filePath;
    public StreamReaderEnumerable(string filePath)
    {
        _filePath = filePath;
    }

    // Must implement GetEnumerator, which returns a new StreamReaderEnumerator.
    public IEnumerator<string> GetEnumerator()
    {
        return new StreamReaderEnumerator(_filePath);
    }

    // Must also implement IEnumerable.GetEnumerator, but implement as a private method.
    private IEnumerator GetEnumerator1()
    {
        return this.GetEnumerator();
    }
    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator1();
    }
}

// When you implement IEnumerable(T), you must also implement IEnumerator(T),
// which will walk through the contents of the file one line at a time.
// Implementing IEnumerator(T) requires that you implement IEnumerator and IDisposable.
public class StreamReaderEnumerator : IEnumerator<string>
{
    private StreamReader _sr;
    public StreamReaderEnumerator(string filePath)
    {
        _sr = new StreamReader(filePath);
    }

    private string _current;
    // Implement the IEnumerator(T).Current publicly, but implement
    // IEnumerator.Current, which is also required, privately.
    public string Current
    {

        get
        {
            if (_sr == null || _current == null)
            {
                throw new InvalidOperationException();
            }

            return _current;
        }
    }

    private object Current1
    {

        get { return this.Current; }
    }

    object IEnumerator.Current
    {
        get { return Current1; }
    }

    // Implement MoveNext and Reset, which are required by IEnumerator.
    public bool MoveNext()
    {
        _current = _sr.ReadLine();
        if (_current == null)
            return false;
        return true;
    }

    public void Reset()
    {
        _sr.DiscardBufferedData();
        _sr.BaseStream.Seek(0, SeekOrigin.Begin);
        _current = null;
    }

    // Implement IDisposable, which is also implemented by IEnumerator(T).
    private bool disposedValue = false;
    public void Dispose()
    {
        Dispose(disposing: true);
        GC.SuppressFinalize(this);
    }

    protected virtual void Dispose(bool disposing)
    {
        if (!this.disposedValue)
        {
            if (disposing)
            {
                // Dispose of managed resources.
            }
            _current = null;
            if (_sr != null) {
               _sr.Close();
               _sr.Dispose();
            }
        }

        this.disposedValue = true;
    }

     ~StreamReaderEnumerator()
    {
        Dispose(disposing: false);
    }
}
// This example displays output similar to the following:
//       Found: 2
//       Memory Used With Iterator =     33kb
//       ---
//       Found: 2
//       Memory Used Without Iterator =  206kb

注釈

IEnumerable<T> は、List<T>Dictionary<TKey,TValue>Stack<T> などの System.Collections.Generic 名前空間のコレクションと、ObservableCollection<T>ConcurrentStack<T>などの他のジェネリック コレクションの基本インターフェイスです。 IEnumerable<T> を実装するコレクションは、foreach ステートメントを使用して列挙できます。

このインターフェイスの非ジェネリック バージョンについては、System.Collections.IEnumerableを参照してください。

IEnumerable<T> には、このインターフェイスを実装するときに実装する必要がある 1 つのメソッドが含まれています。GetEnumerator:IEnumerator<T> オブジェクトを返します。 返される IEnumerator<T> は、Current プロパティを公開することによってコレクションを反復処理する機能を提供します。

注意 (実装者)

非ジェネリック コレクションを反復処理するメソッドとの互換性を維持するために、IEnumerable<T>IEnumerableを実装します。 これにより、ジェネリック コレクションを、IEnumerable オブジェクトを必要とするメソッドに渡すことができます。

メソッド

GetEnumerator()

コレクションを反復処理する列挙子を返します。

拡張メソッド

ToFrozenDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定したキー セレクター関数に従って、IEnumerable<T> から FrozenDictionary<TKey,TValue> を作成します。

ToFrozenDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

指定したキー セレクターおよび要素セレクター関数に従って、IEnumerable<T> から FrozenDictionary<TKey,TValue> を作成します。

ToFrozenSet<T>(IEnumerable<T>, IEqualityComparer<T>)

指定した値を使用して FrozenSet<T> を作成します。

ToImmutableArray<TSource>(IEnumerable<TSource>)

指定したコレクションから変更できない配列を作成します。

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

変換関数をソース キーに適用して、要素の既存のコレクションから変更できないディクショナリを構築します。

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

シーケンスの変換に基づいて、変更できないディクショナリを構築します。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

シーケンスを列挙して変換し、その内容の変更できないディクショナリを生成します。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>)

シーケンスを列挙して変換し、指定したキー比較子を使用してその内容の変更できないディクショナリを生成します。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

シーケンスを列挙して変換し、指定したキーと値の比較子を使用してその内容の変更できないディクショナリを生成します。

ToImmutableHashSet<TSource>(IEnumerable<TSource>)

シーケンスを列挙し、その内容の変更できないハッシュ セットを生成します。

ToImmutableHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

シーケンスを列挙し、その内容の変更できないハッシュ セットを生成し、セット型に対して指定された等値比較子を使用します。

ToImmutableList<TSource>(IEnumerable<TSource>)

シーケンスを列挙し、その内容の変更できないリストを生成します。

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

シーケンスを列挙して変換し、その内容の変更できない並べ替えられたディクショナリを生成します。

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>)

シーケンスを列挙して変換し、指定したキー比較子を使用して、その内容の変更できない並べ替えられたディクショナリを生成します。

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>, IEqualityComparer<TValue>)

シーケンスを列挙して変換し、指定したキーと値の比較子を使用して、その内容の変更できない並べ替えられたディクショナリを生成します。

ToImmutableSortedSet<TSource>(IEnumerable<TSource>)

シーケンスを列挙し、その内容の変更できない並べ替えられたセットを生成します。

ToImmutableSortedSet<TSource>(IEnumerable<TSource>, IComparer<TSource>)

シーケンスを列挙し、その内容の変更できない並べ替えられたセットを生成し、指定された比較子を使用します。

CopyToDataTable<T>(IEnumerable<T>)

ジェネリック パラメーター TDataRowされている入力 IEnumerable<T> オブジェクトを指定して、DataRow オブジェクトのコピーを格納する DataTable を返します。

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

ジェネリック パラメーター TDataRowされている入力 IEnumerable<T> オブジェクトが指定された DataTableDataRow オブジェクトをコピーします。

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

ジェネリック パラメーター TDataRowされている入力 IEnumerable<T> オブジェクトが指定された DataTableDataRow オブジェクトをコピーします。

Aggregate<TSource>(IEnumerable<TSource>, Func<TSource,TSource,TSource>)

アキュムレータ関数をシーケンスに適用します。

Aggregate<TSource,TAccumulate>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>)

アキュムレータ関数をシーケンスに適用します。 指定されたシード値は、初期アキュムレータ値として使用されます。

Aggregate<TSource,TAccumulate,TResult>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TResult>)

アキュムレータ関数をシーケンスに適用します。 指定したシード値が初期アキュムレータ値として使用され、指定された関数を使用して結果値が選択されます。

AggregateBy<TSource,TKey,TAccumulate>(IEnumerable<TSource>, Func<TSource, TKey>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, IEqualityComparer<TKey>)

列挙子を公開します。この列挙子は、指定した型のコレクションに対する単純な反復処理をサポートします。

AggregateBy<TSource,TKey,TAccumulate>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TKey,TAccumulate>, Func<TAccumulate,TSource,TAccumulate>, IEqualityComparer<TKey>)

列挙子を公開します。この列挙子は、指定した型のコレクションに対する単純な反復処理をサポートします。

All<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

シーケンスのすべての要素が条件を満たすかどうかを判断します。

Any<TSource>(IEnumerable<TSource>)

シーケンスに要素が含まれているかどうかを判断します。

Any<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

シーケンスの要素が条件を満たすかどうかを判断します。

Append<TSource>(IEnumerable<TSource>, TSource)

シーケンスの末尾に値を追加します。

AsEnumerable<TSource>(IEnumerable<TSource>)

IEnumerable<T>として入力された入力を返します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Decimal 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Double 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Int32 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Int64 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Decimal 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Double 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Int32 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Int64 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Single 値のシーケンスの平均を計算します。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Single 値のシーケンスの平均を計算します。

Cast<TResult>(IEnumerable)

IEnumerable の要素を指定した型にキャストします。

Chunk<TSource>(IEnumerable<TSource>, Int32)

シーケンスの要素を最大 sizeサイズのチャンクに分割します。

Concat<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

2 つのシーケンスを連結します。

Contains<TSource>(IEnumerable<TSource>, TSource)

既定の等値比較子を使用して、シーケンスに指定した要素が含まれているかどうかを判断します。

Contains<TSource>(IEnumerable<TSource>, TSource, IEqualityComparer<TSource>)

指定した IEqualityComparer<T>を使用して、シーケンスに指定した要素が含まれているかどうかを判断します。

Count<TSource>(IEnumerable<TSource>)

シーケンス内の要素の数を返します。

Count<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

指定したシーケンス内の 1 つの条件を満たす要素の数を表す数値を返します。

CountBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

列挙子を公開します。この列挙子は、指定した型のコレクションに対する単純な反復処理をサポートします。

DefaultIfEmpty<TSource>(IEnumerable<TSource>)

シーケンスが空の場合は、指定したシーケンスの要素、またはシングルトン コレクション内の型パラメーターの既定値を返します。

DefaultIfEmpty<TSource>(IEnumerable<TSource>, TSource)

シーケンスが空の場合は、指定したシーケンスの要素、またはシングルトン コレクション内の指定した値を返します。

Distinct<TSource>(IEnumerable<TSource>)

既定の等値比較子を使用して値を比較することにより、シーケンスから個別の要素を返します。

Distinct<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

指定した IEqualityComparer<T> を使用して値を比較することにより、シーケンスから個別の要素を返します。

DistinctBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、シーケンスから個別の要素を返します。

DistinctBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定したキー セレクター関数に従ってシーケンスから個別の要素を返し、指定した比較子を使用してキーを比較します。

ElementAt<TSource>(IEnumerable<TSource>, Index)

シーケンス内の指定したインデックス位置にある要素を返します。

ElementAt<TSource>(IEnumerable<TSource>, Int32)

シーケンス内の指定したインデックス位置にある要素を返します。

ElementAtOrDefault<TSource>(IEnumerable<TSource>, Index)

シーケンス内の指定したインデックス位置にある要素を返します。インデックスが範囲外の場合は既定値を返します。

ElementAtOrDefault<TSource>(IEnumerable<TSource>, Int32)

シーケンス内の指定したインデックス位置にある要素を返します。インデックスが範囲外の場合は既定値を返します。

Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

既定の等値比較子を使用して値を比較することにより、2 つのシーケンスのセット差を生成します。

Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

指定した IEqualityComparer<T> を使用して値を比較することにより、2 つのシーケンスのセット差を生成します。

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

指定されたキー セレクター関数に従って、2 つのシーケンスのセット差を生成します。

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定されたキー セレクター関数に従って、2 つのシーケンスのセット差を生成します。

First<TSource>(IEnumerable<TSource>)

シーケンスの最初の要素を返します。

First<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

指定した条件を満たすシーケンス内の最初の要素を返します。

FirstOrDefault<TSource>(IEnumerable<TSource>)

シーケンスの最初の要素を返します。シーケンスに要素が含まれている場合は既定値を返します。

FirstOrDefault<TSource>(IEnumerable<TSource>, TSource)

シーケンスの最初の要素を返します。シーケンスに要素が含まれている場合は、指定した既定値を返します。

FirstOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

条件を満たすシーケンスの最初の要素、またはそのような要素が見つからない場合は既定値を返します。

FirstOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>, TSource)

条件を満たすシーケンスの最初の要素を返します。そのような要素が見つからない場合は、指定した既定値を返します。

GroupBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従ってシーケンスの要素をグループ化します。

GroupBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定したキー セレクター関数に従ってシーケンスの要素をグループ化し、指定した比較子を使用してキーを比較します。

GroupBy<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

指定したキー セレクター関数に従ってシーケンスの要素をグループ化し、指定した関数を使用して各グループの要素を投影します。

GroupBy<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

キー セレクター関数に従ってシーケンスの要素をグループ化します。 キーは比較子を使用して比較され、各グループの要素は指定された関数を使用して投影されます。

GroupBy<TSource,TKey,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>)

指定したキー セレクター関数に従ってシーケンスの要素をグループ化し、各グループとそのキーから結果値を作成します。

GroupBy<TSource,TKey,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>, IEqualityComparer<TKey>)

指定したキー セレクター関数に従ってシーケンスの要素をグループ化し、各グループとそのキーから結果値を作成します。 キーは、指定された比較子を使用して比較されます。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>,TResult>)

指定したキー セレクター関数に従ってシーケンスの要素をグループ化し、各グループとそのキーから結果値を作成します。 各グループの要素は、指定された関数を使用して投影されます。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>, TResult>, IEqualityComparer<TKey>)

指定したキー セレクター関数に従ってシーケンスの要素をグループ化し、各グループとそのキーから結果値を作成します。 キー値は指定された比較子を使用して比較され、各グループの要素は指定された関数を使用して投影されます。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>)

キーの等価性に基づいて 2 つのシーケンスの要素を関連付け、結果をグループ化します。 キーの比較には、既定の等値比較子が使用されます。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>, IEqualityComparer<TKey>)

キーの等価性に基づいて 2 つのシーケンスの要素を関連付け、結果をグループ化します。 キーの比較には、指定した IEqualityComparer<T> が使用されます。

Index<TSource>(IEnumerable<TSource>)

要素のインデックスをタプルに組み込む列挙可能な値を返します。

Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

既定の等値比較子を使用して値を比較することにより、2 つのシーケンスの集合積集合を生成します。

Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

指定した IEqualityComparer<T> を使用して値を比較することにより、2 つのシーケンスの集合積集合を生成します。

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、2 つのシーケンスの集合積集合を生成します。

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定したキー セレクター関数に従って、2 つのシーケンスの集合積集合を生成します。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>)

一致するキーに基づいて、2 つのシーケンスの要素を関連付けます。 キーの比較には、既定の等値比較子が使用されます。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>, IEqualityComparer<TKey>)

一致するキーに基づいて、2 つのシーケンスの要素を関連付けます。 キーの比較には、指定した IEqualityComparer<T> が使用されます。

Last<TSource>(IEnumerable<TSource>)

シーケンスの最後の要素を返します。

Last<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

指定した条件を満たすシーケンスの最後の要素を返します。

LastOrDefault<TSource>(IEnumerable<TSource>)

シーケンスの最後の要素を返します。シーケンスに要素が含まれている場合は既定値を返します。

LastOrDefault<TSource>(IEnumerable<TSource>, TSource)

シーケンスの最後の要素を返します。シーケンスに要素が含まれている場合は、指定した既定値を返します。

LastOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

条件を満たすシーケンスの最後の要素、またはそのような要素が見つからない場合は既定値を返します。

LastOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>, TSource)

条件を満たすシーケンスの最後の要素を返します。そのような要素が見つからない場合は、指定された既定値を返します。

LongCount<TSource>(IEnumerable<TSource>)

シーケンス内の要素の合計数を表す Int64 を返します。

LongCount<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

条件を満たすシーケンス内の要素の数を表す Int64 を返します。

Max<TSource>(IEnumerable<TSource>)

ジェネリック シーケンスの最大値を返します。

Max<TSource>(IEnumerable<TSource>, IComparer<TSource>)

ジェネリック シーケンスの最大値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

シーケンスの各要素に対して変換関数を呼び出し、最大 Decimal 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

シーケンスの各要素に対して変換関数を呼び出し、最大 Double 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

シーケンスの各要素に対して変換関数を呼び出し、最大 Int32 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

シーケンスの各要素に対して変換関数を呼び出し、最大 Int64 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最大 Decimal 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最大 Double 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最大 Int32 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最大 Int64 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最大 Single 値を返します。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

シーケンスの各要素に対して変換関数を呼び出し、最大 Single 値を返します。

Max<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

ジェネリック シーケンスの各要素に対して変換関数を呼び出し、結果の最大値を返します。

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、ジェネリック シーケンスの最大値を返します。

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

指定したキー セレクター関数とキー比較子に従って、ジェネリック シーケンスの最大値を返します。

Min<TSource>(IEnumerable<TSource>)

ジェネリック シーケンスの最小値を返します。

Min<TSource>(IEnumerable<TSource>, IComparer<TSource>)

ジェネリック シーケンスの最小値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

シーケンスの各要素に対して変換関数を呼び出し、最小 Decimal 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

シーケンスの各要素に対して変換関数を呼び出し、最小 Double 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

シーケンスの各要素に対して変換関数を呼び出し、最小 Int32 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

シーケンスの各要素に対して変換関数を呼び出し、最小 Int64 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最小 Decimal 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最小 Double 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最小 Int32 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最小 Int64 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の最小 Single 値を返します。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

シーケンスの各要素に対して変換関数を呼び出し、最小 Single 値を返します。

Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

ジェネリック シーケンスの各要素に対して変換関数を呼び出し、結果の最小値を返します。

MinBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、ジェネリック シーケンスの最小値を返します。

MinBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

指定したキー セレクター関数とキー比較子に従って、ジェネリック シーケンスの最小値を返します。

OfType<TResult>(IEnumerable)

指定した型に基づいて、IEnumerable の要素をフィルター処理します。

Order<T>(IEnumerable<T>)

シーケンスの要素を昇順で並べ替えます。

Order<T>(IEnumerable<T>, IComparer<T>)

シーケンスの要素を昇順で並べ替えます。

OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

キーに従って、シーケンスの要素を昇順で並べ替えます。

OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

指定した比較子を使用して、シーケンスの要素を昇順で並べ替えます。

OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

キーに従ってシーケンスの要素を降順に並べ替えます。

OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

指定した比較子を使用して、シーケンスの要素を降順で並べ替えます。

OrderDescending<T>(IEnumerable<T>)

シーケンスの要素を降順で並べ替えます。

OrderDescending<T>(IEnumerable<T>, IComparer<T>)

シーケンスの要素を降順で並べ替えます。

Prepend<TSource>(IEnumerable<TSource>, TSource)

シーケンスの先頭に値を追加します。

Reverse<TSource>(IEnumerable<TSource>)

シーケンス内の要素の順序を反転します。

Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

シーケンスの各要素を新しいフォームに投影します。

Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,Int32,TResult>)

要素のインデックスを組み込んで、シーケンスの各要素を新しいフォームに投影します。

SelectMany<TSource,TResult>(IEnumerable<TSource>, Func<TSource,IEnumerable<TResult>>)

シーケンスの各要素を IEnumerable<T> に投影し、結果のシーケンスを 1 つのシーケンスにフラット化します。

SelectMany<TSource,TResult>(IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TResult>>)

シーケンスの各要素を IEnumerable<T>に投影し、結果のシーケンスを 1 つのシーケンスにフラット化します。 各ソース要素のインデックスは、その要素の投影形式で使用されます。

SelectMany<TSource,TCollection,TResult>(IEnumerable<TSource>, Func<TSource,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

シーケンスの各要素を IEnumerable<T>に投影し、結果のシーケンスを 1 つのシーケンスにフラット化し、その中の各要素に対して結果セレクター関数を呼び出します。

SelectMany<TSource,TCollection,TResult>(IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

シーケンスの各要素を IEnumerable<T>に投影し、結果のシーケンスを 1 つのシーケンスにフラット化し、その中の各要素に対して結果セレクター関数を呼び出します。 各ソース要素のインデックスは、その要素の中間投影形式で使用されます。

SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

型の既定の等値比較子を使用して要素を比較することで、2 つのシーケンスが等しいかどうかを判断します。

SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

指定した IEqualityComparer<T>を使用して要素を比較して、2 つのシーケンスが等しいかどうかを判断します。

Single<TSource>(IEnumerable<TSource>)

シーケンスの唯一の要素を返し、シーケンス内に要素が 1 つだけ存在しない場合は例外をスローします。

Single<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

指定した条件を満たすシーケンスの唯一の要素を返し、そのような要素が複数存在する場合は例外をスローします。

SingleOrDefault<TSource>(IEnumerable<TSource>)

シーケンスの唯一の要素を返します。シーケンスが空の場合は既定値を返します。シーケンス内に複数の要素がある場合、このメソッドは例外をスローします。

SingleOrDefault<TSource>(IEnumerable<TSource>, TSource)

シーケンスの唯一の要素を返します。シーケンスが空の場合は、指定した既定値を返します。シーケンス内に複数の要素がある場合、このメソッドは例外をスローします。

SingleOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

指定した条件を満たすシーケンスの唯一の要素、またはそのような要素が存在しない場合は既定値を返します。このメソッドは、複数の要素が条件を満たす場合に例外をスローします。

SingleOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>, TSource)

指定した条件を満たすシーケンスの唯一の要素、またはそのような要素が存在しない場合は指定された既定値を返します。このメソッドは、複数の要素が条件を満たす場合に例外をスローします。

Skip<TSource>(IEnumerable<TSource>, Int32)

シーケンス内の指定された数の要素をバイパスし、残りの要素を返します。

SkipLast<TSource>(IEnumerable<TSource>, Int32)

ソース コレクションの最後の count 要素を省略した source の要素を含む新しい列挙可能なコレクションを返します。

SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

指定した条件が true である限り、シーケンス内の要素をバイパスし、残りの要素を返します。

SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

指定した条件が true である限り、シーケンス内の要素をバイパスし、残りの要素を返します。 要素のインデックスは、述語関数のロジックで使用されます。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Decimal 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Double 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Int32 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Int64 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Decimal 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Double 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Int32 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Int64 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される null 許容 Single 値のシーケンスの合計を計算します。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

入力シーケンスの各要素で変換関数を呼び出すことによって取得される Single 値のシーケンスの合計を計算します。

Take<TSource>(IEnumerable<TSource>, Int32)

シーケンスの先頭から指定した数の連続する要素を返します。

Take<TSource>(IEnumerable<TSource>, Range)

シーケンスから指定した連続する要素の範囲を返します。

TakeLast<TSource>(IEnumerable<TSource>, Int32)

sourceの最後の count 要素を含む新しい列挙可能なコレクションを返します。

TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

指定した条件が true である限り、シーケンスから要素を返します。

TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

指定した条件が true である限り、シーケンスから要素を返します。 要素のインデックスは、述語関数のロジックで使用されます。

ToArray<TSource>(IEnumerable<TSource>)

IEnumerable<T>から配列を作成します。

ToDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、IEnumerable<T> から Dictionary<TKey,TValue> を作成します。

ToDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定したキー セレクター関数とキー比較子に従って、IEnumerable<T> から Dictionary<TKey,TValue> を作成します。

ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

指定したキー セレクターおよび要素セレクター関数に従って、IEnumerable<T> から Dictionary<TKey,TValue> を作成します。

ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

指定したキー セレクター関数、比較子、および要素セレクター関数に従って、IEnumerable<T> から Dictionary<TKey,TValue> を作成します。

ToHashSet<TSource>(IEnumerable<TSource>)

IEnumerable<T>から HashSet<T> を作成します。

ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

キーを比較する comparer を使用して、IEnumerable<T> から HashSet<T> を作成します。

ToList<TSource>(IEnumerable<TSource>)

IEnumerable<T>から List<T> を作成します。

ToLookup<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、IEnumerable<T> から Lookup<TKey,TElement> を作成します。

ToLookup<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定したキー セレクター関数とキー比較子に従って、IEnumerable<T> から Lookup<TKey,TElement> を作成します。

ToLookup<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

指定したキー セレクターおよび要素セレクター関数に従って、IEnumerable<T> から Lookup<TKey,TElement> を作成します。

ToLookup<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

指定したキー セレクター関数、比較子、および要素セレクター関数に従って、IEnumerable<T> から Lookup<TKey,TElement> を作成します。

TryGetNonEnumeratedCount<TSource>(IEnumerable<TSource>, Int32)

列挙を強制せずに、シーケンス内の要素の数を特定しようとします。

Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

既定の等値比較子を使用して、2 つのシーケンスのセット和集合を生成します。

Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

指定した IEqualityComparer<T>を使用して、2 つのシーケンスのセット和集合を生成します。

UnionBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、2 つのシーケンスのセット和集合を生成します。

UnionBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

指定したキー セレクター関数に従って、2 つのシーケンスのセット和集合を生成します。

Where<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

述語に基づいて値のシーケンスをフィルター処理します。

Where<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

述語に基づいて値のシーケンスをフィルター処理します。 各要素のインデックスは、述語関数のロジックで使用されます。

Zip<TFirst,TSecond>(IEnumerable<TFirst>, IEnumerable<TSecond>)

指定した 2 つのシーケンスの要素を含むタプルのシーケンスを生成します。

Zip<TFirst,TSecond,TThird>(IEnumerable<TFirst>, IEnumerable<TSecond>, IEnumerable<TThird>)

指定された 3 つのシーケンスの要素を持つタプルのシーケンスを生成します。

Zip<TFirst,TSecond,TResult>(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst,TSecond,TResult>)

指定した関数を 2 つのシーケンスの対応する要素に適用し、結果のシーケンスを生成します。

AsParallel(IEnumerable)

クエリの並列化を有効にします。

AsParallel<TSource>(IEnumerable<TSource>)

クエリの並列化を有効にします。

AsQueryable(IEnumerable)

IEnumerableIQueryableに変換します。

AsQueryable<TElement>(IEnumerable<TElement>)

ジェネリック IEnumerable<T> をジェネリック IQueryable<T>に変換します。

Ancestors<T>(IEnumerable<T>)

ソース コレクション内のすべてのノードの先祖を含む要素のコレクションを返します。

Ancestors<T>(IEnumerable<T>, XName)

ソース コレクション内のすべてのノードの先祖を含む要素のフィルター処理されたコレクションを返します。 コレクションには、一致する XName を持つ要素のみが含まれます。

DescendantNodes<T>(IEnumerable<T>)

ソース コレクション内のすべてのドキュメントと要素の子孫ノードのコレクションを返します。

Descendants<T>(IEnumerable<T>)

ソース コレクション内のすべての要素とドキュメントの子孫要素を含む要素のコレクションを返します。

Descendants<T>(IEnumerable<T>, XName)

ソース コレクション内のすべての要素とドキュメントの子孫要素を含む要素のフィルター処理されたコレクションを返します。 コレクションには、一致する XName を持つ要素のみが含まれます。

Elements<T>(IEnumerable<T>)

ソース コレクション内のすべての要素とドキュメントの子要素のコレクションを返します。

Elements<T>(IEnumerable<T>, XName)

ソース コレクション内のすべての要素とドキュメントの子要素のフィルター処理されたコレクションを返します。 コレクションには、一致する XName を持つ要素のみが含まれます。

InDocumentOrder<T>(IEnumerable<T>)

ドキュメントの順序で並べ替えられた、ソース コレクション内のすべてのノードを含むノードのコレクションを返します。

Nodes<T>(IEnumerable<T>)

ソース コレクション内のすべてのドキュメントおよび要素の子ノードのコレクションを返します。

Remove<T>(IEnumerable<T>)

ソース コレクション内のすべてのノードを親ノードから削除します。

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

こちらもご覧ください