KeyedCollection<TKey,TItem> 클래스

정의

키가 값에 포함되어 있는 컬렉션에 대한 추상 기본 클래스를 제공합니다.

generic <typename TKey, typename TItem>
public ref class KeyedCollection abstract : System::Collections::ObjectModel::Collection<TItem>
public abstract class KeyedCollection<TKey,TItem> : System.Collections.ObjectModel.Collection<TItem>
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public abstract class KeyedCollection<TKey,TItem> : System.Collections.ObjectModel.Collection<TItem>
type KeyedCollection<'Key, 'Item> = class
    inherit Collection<'Item>
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type KeyedCollection<'Key, 'Item> = class
    inherit Collection<'Item>
Public MustInherit Class KeyedCollection(Of TKey, TItem)
Inherits Collection(Of TItem)

형식 매개 변수

TKey

컬렉션에 있는 키의 형식입니다.

TItem

컬렉션에 있는 항목의 형식입니다.

상속
Collection<TItem>
KeyedCollection<TKey,TItem>
파생
특성

예제

이 섹션에는 두 코드 예제가 있습니다. 첫 번째 예제에서는 에서 KeyedCollection<TKey,TItem>파생하는 데 필요한 최소 코드를 보여 줍니다. 상속된 여러 메서드를 보여 줍니다. 두 번째 예제에서는 사용자 지정 동작을 제공 하려면 의 보호 된 메서드를 재정의 KeyedCollection<TKey,TItem> 하는 방법을 보여 줍니다.

예제 1

이 코드 예제에서는 에서 KeyedCollection<TKey,TItem>컬렉션 클래스를 파생하는 데 필요한 최소 코드를 보여 줍니다. 메서드를 재정의 GetKeyForItem 하고 기본 클래스 생성자에 위임하는 공용 생성자를 제공합니다. 또한 코드 예제에서는 및 클래스에서 KeyedCollection<TKey,TItem> 상속된 많은 속성 및 Collection<T> 메서드를 보여 줍니다.

클래스는 SimpleOrder 개체를 포함하는 OrderItem 매우 간단한 필수 목록이며, 각 항목은 순서대로 줄 항목을 나타냅니다. 의 OrderItem 키는 변경할 수 없으며 에서 KeyedCollection<TKey,TItem>파생되는 클래스에 대한 중요한 고려 사항입니다. 변경 가능한 키를 사용하는 코드 예제는 를 참조하세요 ChangeItemKey.

using namespace System;
using namespace System::Collections::Generic;
using namespace System::Collections::ObjectModel;

// This class represents a simple line item in an order. All the 
// values are immutable except quantity.
// 
public ref class OrderItem
{
private:
    int _quantity;
    
public:
    initonly int PartNumber;
    initonly String^ Description;
    initonly double UnitPrice;
    
    OrderItem(int partNumber, String^ description, 
        int quantity, double unitPrice)
    {
        this->PartNumber = partNumber;
        this->Description = description;
        this->Quantity = quantity;
        this->UnitPrice = unitPrice;
    } 
    
    property int Quantity    
    {
        int get() { return _quantity; }
        void set(int value)
        {
            if (value < 0)
                throw gcnew ArgumentException("Quantity cannot be negative.");
            
            _quantity = value;
        }
    }
        
    virtual String^ ToString() override 
    {
        return String::Format(
            "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}", 
            PartNumber, _quantity, Description, UnitPrice, 
            UnitPrice * _quantity);
    }
};

// This class represents a very simple keyed list of OrderItems,
// inheriting most of its behavior from the KeyedCollection and 
// Collection classes. The immediate base class is the constructed
// type KeyedCollection<int, OrderItem>. When you inherit
// from KeyedCollection, the second generic type argument is the 
// type that you want to store in the collection -- in this case
// OrderItem. The first type argument is the type that you want
// to use as a key. Its values must be calculated from OrderItem; 
// in this case it is the int field PartNumber, so SimpleOrder
// inherits KeyedCollection<int, OrderItem>.
//
public ref class SimpleOrder : KeyedCollection<int, OrderItem^>
{
    // The parameterless constructor of the base class creates a 
    // KeyedCollection with an internal dictionary. For this code 
    // example, no other constructors are exposed.
    //
public:
    SimpleOrder() {}
    
    // This is the only method that absolutely must be overridden,
    // because without it the KeyedCollection cannot extract the
    // keys from the items. The input parameter type is the 
    // second generic type argument, in this case OrderItem, and 
    // the return value type is the first generic type argument,
    // in this case int.
    //
protected:
    virtual int GetKeyForItem(OrderItem^ item) override 
    {
        // In this example, the key is the part number.
        return item->PartNumber;
    }
};

public ref class Demo
{    
public:
    static void Main()
    {
        SimpleOrder^ weekly = gcnew SimpleOrder();

        // The Add method, inherited from Collection, takes OrderItem.
        //
        weekly->Add(gcnew OrderItem(110072674, "Widget", 400, 45.17));
        weekly->Add(gcnew OrderItem(110072675, "Sprocket", 27, 5.3));
        weekly->Add(gcnew OrderItem(101030411, "Motor", 10, 237.5));
        weekly->Add(gcnew OrderItem(110072684, "Gear", 175, 5.17));
        
        Display(weekly);
    
        // The Contains method of KeyedCollection takes the key, 
        // type, in this case int.
        //
        Console::WriteLine("\nContains(101030411): {0}", 
            weekly->Contains(101030411));

        // The default Item property of KeyedCollection takes a key.
        //
        Console::WriteLine("\nweekly(101030411)->Description: {0}", 
            weekly[101030411]->Description);

        // The Remove method of KeyedCollection takes a key.
        //
        Console::WriteLine("\nRemove(101030411)");
        weekly->Remove(101030411);
        Display(weekly);

        // The Insert method, inherited from Collection, takes an 
        // index and an OrderItem.
        //
        Console::WriteLine("\nInsert(2, New OrderItem(...))");
        weekly->Insert(2, gcnew OrderItem(111033401, "Nut", 10, .5));
        Display(weekly);

        // The default Item property is overloaded. One overload comes
        // from KeyedCollection<int, OrderItem>; that overload
        // is read-only, and takes Integer because it retrieves by key. 
        // The other overload comes from Collection<OrderItem>, the 
        // base class of KeyedCollection<int, OrderItem>; it 
        // retrieves by index, so it also takes an Integer. The compiler
        // uses the most-derived overload, from KeyedCollection, so the
        // only way to access SimpleOrder by index is to cast it to
        // Collection<OrderItem>. Otherwise the index is interpreted
        // as a key, and KeyNotFoundException is thrown.
        //
        Collection<OrderItem^>^ coweekly = weekly;
        Console::WriteLine("\ncoweekly[2].Description: {0}", 
            coweekly[2]->Description);
 
        Console::WriteLine("\ncoweekly[2] = gcnew OrderItem(...)");
        coweekly[2] = gcnew OrderItem(127700026, "Crank", 27, 5.98);

        OrderItem^ temp = coweekly[2];

        // The IndexOf method inherited from Collection<OrderItem> 
        // takes an OrderItem instead of a key
        // 
        Console::WriteLine("\nIndexOf(temp): {0}", weekly->IndexOf(temp));

        // The inherited Remove method also takes an OrderItem.
        //
        Console::WriteLine("\nRemove(temp)");
        weekly->Remove(temp);
        Display(weekly);

        Console::WriteLine("\nRemoveAt(0)");
        weekly->RemoveAt(0);
        Display(weekly);

    }
    
private:
    static void Display(SimpleOrder^ order)
    {
        Console::WriteLine();
        for each( OrderItem^ item in order )
        {
            Console::WriteLine(item);
        }
    }
};

void main()
{
    Demo::Main();
}

/* This code example produces the following output:

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
101030411     10 Motor        at   237.50 =   2,375.00
110072684    175 Gear         at     5.17 =     904.75

Contains(101030411): True

weekly(101030411)->Description: Motor

Remove(101030411)

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
110072684    175 Gear         at     5.17 =     904.75

Insert(2, New OrderItem(...))

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
111033401     10 Nut          at      .50 =       5.00
110072684    175 Gear         at     5.17 =     904.75

coweekly(2)->Description: Nut

coweekly[2] = gcnew OrderItem(...)

IndexOf(temp): 2

Remove(temp)

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
110072684    175 Gear         at     5.17 =     904.75

RemoveAt(0)

110072675     27 Sprocket     at     5.30 =     143.10
110072684    175 Gear         at     5.17 =     904.75
 */
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

// This class represents a very simple keyed list of OrderItems,
// inheriting most of its behavior from the KeyedCollection and
// Collection classes. The immediate base class is the constructed
// type KeyedCollection<int, OrderItem>. When you inherit
// from KeyedCollection, the second generic type argument is the
// type that you want to store in the collection -- in this case
// OrderItem. The first type argument is the type that you want
// to use as a key. Its values must be calculated from OrderItem;
// in this case it is the int field PartNumber, so SimpleOrder
// inherits KeyedCollection<int, OrderItem>.
//
public class SimpleOrder : KeyedCollection<int, OrderItem>
{

    // This is the only method that absolutely must be overridden,
    // because without it the KeyedCollection cannot extract the
    // keys from the items. The input parameter type is the
    // second generic type argument, in this case OrderItem, and
    // the return value type is the first generic type argument,
    // in this case int.
    //
    protected override int GetKeyForItem(OrderItem item)
    {
        // In this example, the key is the part number.
        return item.PartNumber;
    }
}

public class Demo
{
    public static void Main()
    {
        SimpleOrder weekly = new SimpleOrder();

        // The Add method, inherited from Collection, takes OrderItem.
        //
        weekly.Add(new OrderItem(110072674, "Widget", 400, 45.17));
        weekly.Add(new OrderItem(110072675, "Sprocket", 27, 5.3));
        weekly.Add(new OrderItem(101030411, "Motor", 10, 237.5));
        weekly.Add(new OrderItem(110072684, "Gear", 175, 5.17));

        Display(weekly);

        // The Contains method of KeyedCollection takes the key,
        // type, in this case int.
        //
        Console.WriteLine("\nContains(101030411): {0}",
            weekly.Contains(101030411));

        // The default Item property of KeyedCollection takes a key.
        //
        Console.WriteLine("\nweekly[101030411].Description: {0}",
            weekly[101030411].Description);

        // The Remove method of KeyedCollection takes a key.
        //
        Console.WriteLine("\nRemove(101030411)");
        weekly.Remove(101030411);
        Display(weekly);

        // The Insert method, inherited from Collection, takes an
        // index and an OrderItem.
        //
        Console.WriteLine("\nInsert(2, New OrderItem(...))");
        weekly.Insert(2, new OrderItem(111033401, "Nut", 10, .5));
        Display(weekly);

        // The default Item property is overloaded. One overload comes
        // from KeyedCollection<int, OrderItem>; that overload
        // is read-only, and takes Integer because it retrieves by key.
        // The other overload comes from Collection<OrderItem>, the
        // base class of KeyedCollection<int, OrderItem>; it
        // retrieves by index, so it also takes an Integer. The compiler
        // uses the most-derived overload, from KeyedCollection, so the
        // only way to access SimpleOrder by index is to cast it to
        // Collection<OrderItem>. Otherwise the index is interpreted
        // as a key, and KeyNotFoundException is thrown.
        //
        Collection<OrderItem> coweekly = weekly;
        Console.WriteLine("\ncoweekly[2].Description: {0}",
            coweekly[2].Description);

        Console.WriteLine("\ncoweekly[2] = new OrderItem(...)");
        coweekly[2] = new OrderItem(127700026, "Crank", 27, 5.98);

        OrderItem temp = coweekly[2];

        // The IndexOf method inherited from Collection<OrderItem>
        // takes an OrderItem instead of a key
        //
        Console.WriteLine("\nIndexOf(temp): {0}", weekly.IndexOf(temp));

        // The inherited Remove method also takes an OrderItem.
        //
        Console.WriteLine("\nRemove(temp)");
        weekly.Remove(temp);
        Display(weekly);

        Console.WriteLine("\nRemoveAt(0)");
        weekly.RemoveAt(0);
        Display(weekly);
    }

    private static void Display(SimpleOrder order)
    {
        Console.WriteLine();
        foreach( OrderItem item in order )
        {
            Console.WriteLine(item);
        }
    }
}

// This class represents a simple line item in an order. All the
// values are immutable except quantity.
//
public class OrderItem
{
    public readonly int PartNumber;
    public readonly string Description;
    public readonly double UnitPrice;

    private int _quantity = 0;

    public OrderItem(int partNumber, string description,
        int quantity, double unitPrice)
    {
        this.PartNumber = partNumber;
        this.Description = description;
        this.Quantity = quantity;
        this.UnitPrice = unitPrice;
    }

    public int Quantity
    {
        get { return _quantity; }
        set
        {
            if (value<0)
                throw new ArgumentException("Quantity cannot be negative.");

            _quantity = value;
        }
    }

    public override string ToString()
    {
        return String.Format(
            "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}",
            PartNumber, _quantity, Description, UnitPrice,
            UnitPrice * _quantity);
    }
}

/* This code example produces the following output:

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
101030411     10 Motor        at   237.50 =   2,375.00
110072684    175 Gear         at     5.17 =     904.75

Contains(101030411): True

weekly[101030411].Description: Motor

Remove(101030411)

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
110072684    175 Gear         at     5.17 =     904.75

Insert(2, New OrderItem(...))

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
111033401     10 Nut          at      .50 =       5.00
110072684    175 Gear         at     5.17 =     904.75

coweekly[2].Description: Nut

coweekly[2] = new OrderItem(...)

IndexOf(temp): 2

Remove(temp)

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
110072684    175 Gear         at     5.17 =     904.75

RemoveAt(0)

110072675     27 Sprocket     at     5.30 =     143.10
110072684    175 Gear         at     5.17 =     904.75
 */
Imports System.Collections.Generic
Imports System.Collections.ObjectModel

' This class represents a very simple keyed list of OrderItems,
' inheriting most of its behavior from the KeyedCollection and 
' Collection classes. The immediate base class is the constructed
' type KeyedCollection(Of Integer, OrderItem). When you inherit
' from KeyedCollection, the second generic type argument is the 
' type that you want to store in the collection -- in this case
' OrderItem. The first generic argument is the type that you want
' to use as a key. Its values must be calculated from OrderItem; 
' in this case it is the Integer field PartNumber, so SimpleOrder
' inherits KeyedCollection(Of Integer, OrderItem).
'
Public Class SimpleOrder
    Inherits KeyedCollection(Of Integer, OrderItem)


    ' This is the only method that absolutely must be overridden,
    ' because without it the KeyedCollection cannot extract the
    ' keys from the items. The input parameter type is the 
    ' second generic type argument, in this case OrderItem, and 
    ' the return value type is the first generic type argument,
    ' in this case Integer.
    '
    Protected Overrides Function GetKeyForItem( _
        ByVal item As OrderItem) As Integer

        ' In this example, the key is the part number.
        Return item.PartNumber   
    End Function

End Class

Public Class Demo
    
    Public Shared Sub Main() 
        Dim weekly As New SimpleOrder()

        ' The Add method, inherited from Collection, takes OrderItem.
        '
        weekly.Add(New OrderItem(110072674, "Widget", 400, 45.17))
        weekly.Add(New OrderItem(110072675, "Sprocket", 27, 5.3))
        weekly.Add(New OrderItem(101030411, "Motor", 10, 237.5))
        weekly.Add(New OrderItem(110072684, "Gear", 175, 5.17))
        
        Display(weekly)
    
        ' The Contains method of KeyedCollection takes TKey.
        '
        Console.WriteLine(vbLf & "Contains(101030411): {0}", _
            weekly.Contains(101030411))

        ' The default Item property of KeyedCollection takes the key
        ' type, Integer.
        '
        Console.WriteLine(vbLf & "weekly(101030411).Description: {0}", _
            weekly(101030411).Description)

        ' The Remove method of KeyedCollection takes a key.
        '
        Console.WriteLine(vbLf & "Remove(101030411)")
        weekly.Remove(101030411)
        Display(weekly)

        ' The Insert method, inherited from Collection, takes an 
        ' index and an OrderItem.
        '
        Console.WriteLine(vbLf & "Insert(2, New OrderItem(...))")
        weekly.Insert(2, New OrderItem(111033401, "Nut", 10, .5))
        Display(weekly)

        ' The default Item property is overloaded. One overload comes
        ' from KeyedCollection(Of Integer, OrderItem); that overload
        ' is read-only, and takes Integer because it retrieves by key. 
        ' The other overload comes from Collection(Of OrderItem), the 
        ' base class of KeyedCollection(Of Integer, OrderItem); it 
        ' retrieves by index, so it also takes an Integer. The compiler
        ' uses the most-derived overload, from KeyedCollection, so the
        ' only way to access SimpleOrder by index is to cast it to
        ' Collection(Of OrderItem). Otherwise the index is interpreted
        ' as a key, and KeyNotFoundException is thrown.
        '
        Dim coweekly As Collection(Of OrderItem) = weekly
        Console.WriteLine(vbLf & "coweekly(2).Description: {0}", _
            coweekly(2).Description)
 
        Console.WriteLine(vbLf & "coweekly(2) = New OrderItem(...)")
        coweekly(2) = New OrderItem(127700026, "Crank", 27, 5.98)

        Dim temp As OrderItem = coweekly(2)

        ' The IndexOf method, inherited from Collection(Of OrderItem), 
        ' takes an OrderItem instead of a key.
        ' 
        Console.WriteLine(vbLf & "IndexOf(temp): {0}", _
            weekly.IndexOf(temp))

        ' The inherited Remove method also takes an OrderItem.
        '
        Console.WriteLine(vbLf & "Remove(temp)")
        weekly.Remove(temp)
        Display(weekly)

        Console.WriteLine(vbLf & "RemoveAt(0)")
        weekly.RemoveAt(0)
        Display(weekly)

    End Sub
    
    Private Shared Sub Display(ByVal order As SimpleOrder) 
        Console.WriteLine()
        For Each item As OrderItem In  order
            Console.WriteLine(item)
        Next item
    End Sub
End Class

' This class represents a simple line item in an order. All the 
' values are immutable except quantity.
' 
Public Class OrderItem
    Public ReadOnly PartNumber As Integer
    Public ReadOnly Description As String
    Public ReadOnly UnitPrice As Double
    
    Private _quantity As Integer = 0
    
    Public Sub New(ByVal partNumber As Integer, _
                   ByVal description As String, _
                   ByVal quantity As Integer, _
                   ByVal unitPrice As Double) 
        Me.PartNumber = partNumber
        Me.Description = description
        Me.Quantity = quantity
        Me.UnitPrice = unitPrice
    End Sub
    
    Public Property Quantity() As Integer 
        Get
            Return _quantity
        End Get
        Set
            If value < 0 Then
                Throw New ArgumentException("Quantity cannot be negative.")
            End If
            _quantity = value
        End Set
    End Property
        
    Public Overrides Function ToString() As String 
        Return String.Format( _
            "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}", _
            PartNumber, _quantity, Description, UnitPrice, _
            UnitPrice * _quantity)
    End Function
End Class

' This code example produces the following output:
'
'110072674    400 Widget       at    45.17 =  18,068.00
'110072675     27 Sprocket     at     5.30 =     143.10
'101030411     10 Motor        at   237.50 =   2,375.00
'110072684    175 Gear         at     5.17 =     904.75
'
'Contains(101030411): True
'
'weekly(101030411).Description: Motor
'
'Remove(101030411)
'
'110072674    400 Widget       at    45.17 =  18,068.00
'110072675     27 Sprocket     at     5.30 =     143.10
'110072684    175 Gear         at     5.17 =     904.75
'
'Insert(2, New OrderItem(...))
'
'110072674    400 Widget       at    45.17 =  18,068.00
'110072675     27 Sprocket     at     5.30 =     143.10
'111033401     10 Nut          at      .50 =       5.00
'110072684    175 Gear         at     5.17 =     904.75
'
'coweekly(2).Description: Nut
'
'coweekly(2) = New OrderItem(...)
'
'IndexOf(temp): 2
'
'Remove(temp)
'
'110072674    400 Widget       at    45.17 =  18,068.00
'110072675     27 Sprocket     at     5.30 =     143.10
'110072684    175 Gear         at     5.17 =     904.75
'
'RemoveAt(0)
'
'110072675     27 Sprocket     at     5.30 =     143.10
'110072684    175 Gear         at     5.17 =     904.75

예제 2

다음 코드 예제에서는 보호된 InsertItem, , RemoveItemClearItems및 메서드를 재정의하여 , RemoveSetItem 메서드에 대한 Add사용자 지정 동작을 Clear 제공하고 기본 Item[] 속성(C#의 인덱서)을 설정하는 방법을 보여 줍니다. 이 예제에서 제공하는 사용자 지정 동작은 재정의된 각 메서드의 끝에서 발생하는 라는 Changed알림 이벤트입니다.

코드 예제에서는 에서 파생 되는 클래스를 KeyedCollection<TKey,TItem> 만들고 SimpleOrder 간단한 순서 폼을 나타냅니다. 주문 양식에는 OrderItem 정렬된 항목을 나타내는 개체가 포함되어 있습니다. 또한 코드 예제는 이벤트 정보를 포함 하는 클래스 및 변경 형식을 식별 하는 열거형을 만듭니다 SimpleOrderChangedEventArgs .

이 코드 예제에서는 클래스의 메서드에서 파생 클래스의 속성 및 메서드를 호출하여 사용자 지정 동작을 MainDemo 보여 줍니다.

이 코드 예제에서는 변경할 수 없는 키가 있는 개체를 사용합니다. 변경 가능한 키를 사용하는 코드 예제는 를 참조하세요 ChangeItemKey.

using namespace System;
using namespace System::Collections::Generic;
using namespace System::Collections::ObjectModel;

public enum class ChangeTypes
{
    Added,
    Removed, 
    Replaced, 
    Cleared
};

ref class SimpleOrderChangedEventArgs; 

// This class represents a simple line item in an order. All the 
// values are immutable except quantity.
// 
public ref class OrderItem
{
private:
    int _quantity;

public:
    initonly int PartNumber;
    initonly String^ Description;
    initonly double UnitPrice;
        
    OrderItem(int partNumber, String^ description, int quantity, 
        double unitPrice)
    {
        this->PartNumber = partNumber;
        this->Description = description;
        this->Quantity = quantity;
        this->UnitPrice = unitPrice;
    };
    
    property int Quantity    
    {
        int get() { return _quantity; };
        void set(int value)
        {
            if (value < 0)
                throw gcnew ArgumentException("Quantity cannot be negative.");
            
            _quantity = value;
        };
    };
        
    virtual String^ ToString() override 
    {
        return String::Format(
            "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}", 
            PartNumber, _quantity, Description, UnitPrice, 
            UnitPrice * _quantity);
    };
};

// Event argument for the Changed event.
//
public ref class SimpleOrderChangedEventArgs : EventArgs
{
public:
    OrderItem^ ChangedItem;
    initonly ChangeTypes ChangeType;
    OrderItem^ ReplacedWith;

    SimpleOrderChangedEventArgs(ChangeTypes change, 
        OrderItem^ item, OrderItem^ replacement)
    {
        this->ChangeType = change;
        this->ChangedItem = item;
        this->ReplacedWith = replacement;
    }
};

// This class derives from KeyedCollection and shows how to override
// the protected ClearItems, InsertItem, RemoveItem, and SetItem 
// methods in order to change the behavior of the default Item 
// property and the Add, Clear, Insert, and Remove methods. The
// class implements a Changed event, which is raised by all the
// protected methods.
//
// SimpleOrder is a collection of OrderItem objects, and its key
// is the PartNumber field of OrderItem-> PartNumber is an Integer,
// so SimpleOrder inherits KeyedCollection<int, OrderItem>.
// (Note that the key of OrderItem cannot be changed; if it could 
// be changed, SimpleOrder would have to override ChangeItemKey.)
//
public ref class SimpleOrder : KeyedCollection<int, OrderItem^>
{
public:
    event EventHandler<SimpleOrderChangedEventArgs^>^ Changed;

    // This parameterless constructor calls the base class constructor
    // that specifies a dictionary threshold of 0, so that the internal
    // dictionary is created as soon as an item is added to the 
    // collection.
    //
    SimpleOrder() : KeyedCollection<int, OrderItem^>(nullptr, 0) {};
    
    // This is the only method that absolutely must be overridden,
    // because without it the KeyedCollection cannot extract the
    // keys from the items. 
    //
protected:
    virtual int GetKeyForItem(OrderItem^ item) override
    {
        // In this example, the key is the part number.
        return item->PartNumber;
    }

    virtual void InsertItem(int index, OrderItem^ newItem) override 
    {
        __super::InsertItem(index, newItem);

        Changed(this, gcnew SimpleOrderChangedEventArgs(
            ChangeTypes::Added, newItem, nullptr));
    }

    virtual void SetItem(int index, OrderItem^ newItem) override 
    {
        OrderItem^ replaced = this->Items[index];
        __super::SetItem(index, newItem);

        Changed(this, gcnew SimpleOrderChangedEventArgs(
            ChangeTypes::Replaced, replaced, newItem));
    }

    virtual void RemoveItem(int index) override 
    {
        OrderItem^ removedItem = Items[index];
        __super::RemoveItem(index);

        Changed(this, gcnew SimpleOrderChangedEventArgs(
            ChangeTypes::Removed, removedItem, nullptr));
    }

    virtual void ClearItems() override 
    {
        __super::ClearItems();

        Changed(this, gcnew SimpleOrderChangedEventArgs(
            ChangeTypes::Cleared, nullptr, nullptr));
    }

    // This method uses the internal reference to the dictionary
    // to test fo
public:
    void AddOrMerge(OrderItem^ newItem)
    {

        int key = this->GetKeyForItem(newItem);
        OrderItem^ existingItem = nullptr;

        // The dictionary is not created until the first item is 
        // added, so it is necessary to test for null. Using 
        // AndAlso ensures that TryGetValue is not called if the
        // dictionary does not exist.
        //
        if (this->Dictionary != nullptr && 
            this->Dictionary->TryGetValue(key, existingItem))
        {
            existingItem->Quantity += newItem->Quantity;
        }
        else
        {
            this->Add(newItem);
        }
    }
};

public ref class Demo
{    
public:
    static void Main()
    {
        SimpleOrder^ weekly = gcnew SimpleOrder();
        weekly->Changed += gcnew 
            EventHandler<SimpleOrderChangedEventArgs^>(ChangedHandler);

        // The Add method, inherited from Collection, takes OrderItem->
        //
        weekly->Add(gcnew OrderItem(110072674, "Widget", 400, 45.17));
        weekly->Add(gcnew OrderItem(110072675, "Sprocket", 27, 5.3));
        weekly->Add(gcnew OrderItem(101030411, "Motor", 10, 237.5));
        weekly->Add(gcnew OrderItem(110072684, "Gear", 175, 5.17));

        Display(weekly);
        
        // The Contains method of KeyedCollection takes TKey.
        //
        Console::WriteLine("\nContains(101030411): {0}", 
            weekly->Contains(101030411));

        // The default Item property of KeyedCollection takes the key
        // type, Integer. The property is read-only.
        //
        Console::WriteLine("\nweekly[101030411]->Description: {0}", 
            weekly[101030411]->Description);

        // The Remove method of KeyedCollection takes a key.
        //
        Console::WriteLine("\nRemove(101030411)");
        weekly->Remove(101030411);

        // The Insert method, inherited from Collection, takes an 
        // index and an OrderItem.
        //
        Console::WriteLine("\nInsert(2, gcnew OrderItem(...))");
        weekly->Insert(2, gcnew OrderItem(111033401, "Nut", 10, .5));
         
        // The default Item property is overloaded. One overload comes
        // from KeyedCollection<int, OrderItem>; that overload
        // is read-only, and takes Integer because it retrieves by key. 
        // The other overload comes from Collection<OrderItem>, the 
        // base class of KeyedCollection<int, OrderItem>; it 
        // retrieves by index, so it also takes an Integer. The compiler
        // uses the most-derived overload, from KeyedCollection, so the
        // only way to access SimpleOrder by index is to cast it to
        // Collection<OrderItem>. Otherwise the index is interpreted
        // as a key, and KeyNotFoundException is thrown.
        //
        Collection<OrderItem^>^ coweekly = weekly;
        Console::WriteLine("\ncoweekly[2].Description: {0}", 
            coweekly[2]->Description);
 
        Console::WriteLine("\ncoweekly[2] = gcnew OrderItem(...)");
        coweekly[2] = gcnew OrderItem(127700026, "Crank", 27, 5.98);

        OrderItem^ temp = coweekly[2];

        // The IndexOf method, inherited from Collection<OrderItem>, 
        // takes an OrderItem instead of a key.
        // 
        Console::WriteLine("\nIndexOf(temp): {0}", weekly->IndexOf(temp));

        // The inherited Remove method also takes an OrderItem->
        //
        Console::WriteLine("\nRemove(temp)");
        weekly->Remove(temp);

        Console::WriteLine("\nRemoveAt(0)");
        weekly->RemoveAt(0);

        weekly->AddOrMerge(gcnew OrderItem(110072684, "Gear", 1000, 5.17));

        Display(weekly);

        Console::WriteLine();
        weekly->Clear();
    }
    
private:
    static void Display(SimpleOrder^ order)
    {
        Console::WriteLine();
        for each( OrderItem^ item in order )
        {
            Console::WriteLine(item);
        }
    }

    static void ChangedHandler(Object^ source, 
        SimpleOrderChangedEventArgs^ e)
    {
        OrderItem^ item = e->ChangedItem;

        if (e->ChangeType == ChangeTypes::Replaced)
        {
            OrderItem^ replacement = e->ReplacedWith;

            Console::WriteLine("{0} (quantity {1}) was replaced " +
                "by {2}, (quantity {3}).", item->Description, 
                item->Quantity, replacement->Description, 
                replacement->Quantity);
        }
        else if(e->ChangeType == ChangeTypes::Cleared)
        {
            Console::WriteLine("The order list was cleared.");
        }
        else
        {
            Console::WriteLine("{0} (quantity {1}) was {2}.", 
                item->Description, item->Quantity, e->ChangeType);
        }
    }
};

void main()
{
    Demo::Main();
}

/* This code example produces the following output:

Widget (quantity 400) was Added.
Sprocket (quantity 27) was Added.
Motor (quantity 10) was Added.
Gear (quantity 175) was Added.

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
101030411     10 Motor        at   237.50 =   2,375.00
110072684    175 Gear         at     5.17 =     904.75

Contains(101030411): True

weekly[101030411]->Description: Motor

Remove(101030411)
Motor (quantity 10) was Removed.

Insert(2, gcnew OrderItem(...))
Nut (quantity 10) was Added.

coweekly[2].Description: Nut

coweekly[2] = gcnew OrderItem(...)
Nut (quantity 10) was replaced by Crank, (quantity 27).

IndexOf(temp): 2

Remove(temp)
Crank (quantity 27) was Removed.

RemoveAt(0)
Widget (quantity 400) was Removed.

110072675     27 Sprocket     at     5.30 =     143.10
110072684   1175 Gear         at     5.17 =   6,074.75

The order list was cleared.
 */
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

// This class derives from KeyedCollection and shows how to override
// the protected ClearItems, InsertItem, RemoveItem, and SetItem
// methods in order to change the behavior of the default Item
// property and the Add, Clear, Insert, and Remove methods. The
// class implements a Changed event, which is raised by all the
// protected methods.
//
// SimpleOrder is a collection of OrderItem objects, and its key
// is the PartNumber field of OrderItem. PartNumber is an Integer,
// so SimpleOrder inherits KeyedCollection<int, OrderItem>.
// (Note that the key of OrderItem cannot be changed; if it could
// be changed, SimpleOrder would have to override ChangeItemKey.)
//
public class SimpleOrder : KeyedCollection<int, OrderItem>
{
    public event EventHandler<SimpleOrderChangedEventArgs> Changed;

    // This parameterless constructor calls the base class constructor
    // that specifies a dictionary threshold of 0, so that the internal
    // dictionary is created as soon as an item is added to the
    // collection.
    //
    public SimpleOrder() : base(null, 0) {}

    // This is the only method that absolutely must be overridden,
    // because without it the KeyedCollection cannot extract the
    // keys from the items.
    //
    protected override int GetKeyForItem(OrderItem item)
    {
        // In this example, the key is the part number.
        return item.PartNumber;
    }

    protected override void InsertItem(int index, OrderItem newItem)
    {
        base.InsertItem(index, newItem);

        EventHandler<SimpleOrderChangedEventArgs> temp = Changed;
        if (temp != null)
        {
            temp(this, new SimpleOrderChangedEventArgs(
                ChangeType.Added, newItem, null));
        }
    }

    protected override void SetItem(int index, OrderItem newItem)
    {
        OrderItem replaced = Items[index];
        base.SetItem(index, newItem);

        EventHandler<SimpleOrderChangedEventArgs> temp = Changed;
        if (temp != null)
        {
            temp(this, new SimpleOrderChangedEventArgs(
                ChangeType.Replaced, replaced, newItem));
        }
    }

    protected override void RemoveItem(int index)
    {
        OrderItem removedItem = Items[index];
        base.RemoveItem(index);

        EventHandler<SimpleOrderChangedEventArgs> temp = Changed;
        if (temp != null)
        {
            temp(this, new SimpleOrderChangedEventArgs(
                ChangeType.Removed, removedItem, null));
        }
    }

    protected override void ClearItems()
    {
        base.ClearItems();

        EventHandler<SimpleOrderChangedEventArgs> temp = Changed;
        if (temp != null)
        {
            temp(this, new SimpleOrderChangedEventArgs(
                ChangeType.Cleared, null, null));
        }
    }
}

// Event argument for the Changed event.
//
public class SimpleOrderChangedEventArgs : EventArgs
{
    private OrderItem _changedItem;
    private ChangeType _changeType;
    private OrderItem _replacedWith;

    public OrderItem ChangedItem { get { return _changedItem; }}
    public ChangeType ChangeType { get { return _changeType; }}
    public OrderItem ReplacedWith { get { return _replacedWith; }}

    public SimpleOrderChangedEventArgs(ChangeType change,
        OrderItem item, OrderItem replacement)
    {
        _changeType = change;
        _changedItem = item;
        _replacedWith = replacement;
    }
}

public enum ChangeType
{
    Added,
    Removed,
    Replaced,
    Cleared
};

public class Demo
{
    public static void Main()
    {
        SimpleOrder weekly = new SimpleOrder();
        weekly.Changed += new
            EventHandler<SimpleOrderChangedEventArgs>(ChangedHandler);

        // The Add method, inherited from Collection, takes OrderItem.
        //
        weekly.Add(new OrderItem(110072674, "Widget", 400, 45.17));
        weekly.Add(new OrderItem(110072675, "Sprocket", 27, 5.3));
        weekly.Add(new OrderItem(101030411, "Motor", 10, 237.5));
        weekly.Add(new OrderItem(110072684, "Gear", 175, 5.17));

        Display(weekly);

        // The Contains method of KeyedCollection takes TKey.
        //
        Console.WriteLine("\nContains(101030411): {0}",
            weekly.Contains(101030411));

        // The default Item property of KeyedCollection takes the key
        // type, Integer. The property is read-only.
        //
        Console.WriteLine("\nweekly[101030411].Description: {0}",
            weekly[101030411].Description);

        // The Remove method of KeyedCollection takes a key.
        //
        Console.WriteLine("\nRemove(101030411)");
        weekly.Remove(101030411);

        // The Insert method, inherited from Collection, takes an
        // index and an OrderItem.
        //
        Console.WriteLine("\nInsert(2, new OrderItem(...))");
        weekly.Insert(2, new OrderItem(111033401, "Nut", 10, .5));

        // The default Item property is overloaded. One overload comes
        // from KeyedCollection<int, OrderItem>; that overload
        // is read-only, and takes Integer because it retrieves by key.
        // The other overload comes from Collection<OrderItem>, the
        // base class of KeyedCollection<int, OrderItem>; it
        // retrieves by index, so it also takes an Integer. The compiler
        // uses the most-derived overload, from KeyedCollection, so the
        // only way to access SimpleOrder by index is to cast it to
        // Collection<OrderItem>. Otherwise the index is interpreted
        // as a key, and KeyNotFoundException is thrown.
        //
        Collection<OrderItem> coweekly = weekly;
        Console.WriteLine("\ncoweekly[2].Description: {0}",
            coweekly[2].Description);

        Console.WriteLine("\ncoweekly[2] = new OrderItem(...)");
        coweekly[2] = new OrderItem(127700026, "Crank", 27, 5.98);

        OrderItem temp = coweekly[2];

        // The IndexOf method, inherited from Collection<OrderItem>,
        // takes an OrderItem instead of a key.
        //
        Console.WriteLine("\nIndexOf(temp): {0}", weekly.IndexOf(temp));

        // The inherited Remove method also takes an OrderItem.
        //
        Console.WriteLine("\nRemove(temp)");
        weekly.Remove(temp);

        Console.WriteLine("\nRemoveAt(0)");
        weekly.RemoveAt(0);

        // Increase the quantity for a line item.
        Console.WriteLine("\ncoweekly(1) = New OrderItem(...)");
        coweekly[1] = new OrderItem(coweekly[1].PartNumber,
            coweekly[1].Description, coweekly[1].Quantity + 1000,
            coweekly[1].UnitPrice);

        Display(weekly);

        Console.WriteLine();
        weekly.Clear();
    }

    private static void Display(SimpleOrder order)
    {
        Console.WriteLine();
        foreach( OrderItem item in order )
        {
            Console.WriteLine(item);
        }
    }

    private static void ChangedHandler(object source,
        SimpleOrderChangedEventArgs e)
    {

        OrderItem item = e.ChangedItem;

        if (e.ChangeType==ChangeType.Replaced)
        {
            OrderItem replacement = e.ReplacedWith;

            Console.WriteLine("{0} (quantity {1}) was replaced " +
                "by {2}, (quantity {3}).", item.Description,
                item.Quantity, replacement.Description,
                replacement.Quantity);
        }
        else if(e.ChangeType == ChangeType.Cleared)
        {
            Console.WriteLine("The order list was cleared.");
        }
        else
        {
            Console.WriteLine("{0} (quantity {1}) was {2}.",
                item.Description, item.Quantity, e.ChangeType);
        }
    }
}

// This class represents a simple line item in an order. All the
// values are immutable except quantity.
//
public class OrderItem
{
    private int _partNumber;
    private string _description;
    private double _unitPrice;
    private int _quantity;

    public int PartNumber { get { return _partNumber; }}
    public string Description { get { return _description; }}
    public double UnitPrice { get { return _unitPrice; }}
    public int Quantity { get { return _quantity; }}

    public OrderItem(int partNumber, string description, int quantity,
        double unitPrice)
    {
        _partNumber = partNumber;
        _description = description;
        _quantity = quantity;
        _unitPrice = unitPrice;
    }

    public override string ToString()
    {
        return String.Format(
            "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}",
            PartNumber, _quantity, Description, UnitPrice,
            UnitPrice * _quantity);
    }
}

/* This code example produces the following output:

Widget (quantity 400) was Added.
Sprocket (quantity 27) was Added.
Motor (quantity 10) was Added.
Gear (quantity 175) was Added.

110072674    400 Widget       at    45.17 =  18,068.00
110072675     27 Sprocket     at     5.30 =     143.10
101030411     10 Motor        at   237.50 =   2,375.00
110072684    175 Gear         at     5.17 =     904.75

Contains(101030411): True

weekly[101030411].Description: Motor

Remove(101030411)
Motor (quantity 10) was Removed.

Insert(2, new OrderItem(...))
Nut (quantity 10) was Added.

coweekly[2].Description: Nut

coweekly[2] = new OrderItem(...)
Nut (quantity 10) was replaced by Crank, (quantity 27).

IndexOf(temp): 2

Remove(temp)
Crank (quantity 27) was Removed.

RemoveAt(0)
Widget (quantity 400) was Removed.

coweekly(1) = New OrderItem(...)
Gear (quantity 175) was replaced by Gear, (quantity 1175).

110072675     27 Sprocket     at     5.30 =     143.10
110072684   1175 Gear         at     5.17 =   6,074.75

The order list was cleared.
 */
Imports System.Collections.Generic
Imports System.Collections.ObjectModel

' This class derives from KeyedCollection and shows how to override
' the protected ClearItems, InsertItem, RemoveItem, and SetItem 
' methods in order to change the behavior of the default Item 
' property and the Add, Clear, Insert, and Remove methods. The
' class implements a Changed event, which is raised by all the
' protected methods.
'
' SimpleOrder is a collection of OrderItem objects, and its key
' is the PartNumber field of OrderItem. PartNumber is an Integer,
' so SimpleOrder inherits KeyedCollection(Of Integer, OrderItem).
' (Note that the key of OrderItem cannot be changed; if it could 
' be changed, SimpleOrder would have to override ChangeItemKey.)
'
Public Class SimpleOrder
    Inherits KeyedCollection(Of Integer, OrderItem)

    Public Event Changed As EventHandler(Of SimpleOrderChangedEventArgs)

    ' This parameterless constructor calls the base class constructor
    ' that specifies a dictionary threshold of 0, so that the internal
    ' dictionary is created as soon as an item is added to the 
    ' collection.
    '
    Public Sub New()
        MyBase.New(Nothing, 0)
    End Sub
    
    ' This is the only method that absolutely must be overridden,
    ' because without it the KeyedCollection cannot extract the
    ' keys from the items. 
    '
    Protected Overrides Function GetKeyForItem( _
        ByVal item As OrderItem) As Integer

        ' In this example, the key is the part number.
        Return item.PartNumber   
    End Function

    Protected Overrides Sub InsertItem( _
        ByVal index As Integer, ByVal newItem As OrderItem)

        MyBase.InsertItem(index, newItem)

        RaiseEvent Changed(Me, New SimpleOrderChangedEventArgs( _
            ChangeType.Added, newItem, Nothing))
    End Sub

    Protected Overrides Sub SetItem(ByVal index As Integer, _
        ByVal newItem As OrderItem)

        Dim replaced As OrderItem = Items(index)
        MyBase.SetItem(index, newItem)

        RaiseEvent Changed(Me, New SimpleOrderChangedEventArgs( _
            ChangeType.Replaced, replaced, newItem))
    End Sub

    Protected Overrides Sub RemoveItem(ByVal index As Integer)

        Dim removedItem As OrderItem = Items(index)
        MyBase.RemoveItem(index)

        RaiseEvent Changed(Me, New SimpleOrderChangedEventArgs( _
            ChangeType.Removed, removedItem, Nothing))
    End Sub

    Protected Overrides Sub ClearItems()
        MyBase.ClearItems()

        RaiseEvent Changed(Me, New SimpleOrderChangedEventArgs( _
            ChangeType.Cleared, Nothing, Nothing))
    End Sub

End Class

' Event argument for the Changed event.
'
Public Class SimpleOrderChangedEventArgs
    Inherits EventArgs

    Private _changedItem As OrderItem
    Private _changeType As ChangeType
    Private _replacedWith As OrderItem

    Public ReadOnly Property ChangedItem As OrderItem
        Get
            Return _changedItem
        End Get
    End Property

    Public ReadOnly Property ChangeType As ChangeType
        Get
            Return _changeType
        End Get
    End Property

    Public ReadOnly Property ReplacedWith As OrderItem
        Get
            Return _replacedWith
        End Get
    End Property

    Public Sub New(ByVal change As ChangeType, ByVal item As OrderItem, _
        ByVal replacement As OrderItem)

        _changeType = change
        _changedItem = item
        _replacedWith = replacement
    End Sub
End Class

Public Enum ChangeType
    Added
    Removed
    Replaced
    Cleared
End Enum

Public Class Demo
    
    Public Shared Sub Main() 
        Dim weekly As New SimpleOrder()
        AddHandler weekly.Changed, AddressOf ChangedHandler

        ' The Add method, inherited from Collection, takes OrderItem.
        '
        weekly.Add(New OrderItem(110072674, "Widget", 400, 45.17))
        weekly.Add(New OrderItem(110072675, "Sprocket", 27, 5.3))
        weekly.Add(New OrderItem(101030411, "Motor", 10, 237.5))
        weekly.Add(New OrderItem(110072684, "Gear", 175, 5.17))

        Display(weekly)
        
        ' The Contains method of KeyedCollection takes TKey.
        '
        Console.WriteLine(vbLf & "Contains(101030411): {0}", _
            weekly.Contains(101030411))

        ' The default Item property of KeyedCollection takes the key
        ' type, Integer. The property is read-only.
        '
        Console.WriteLine(vbLf & "weekly(101030411).Description: {0}", _
            weekly(101030411).Description)

        ' The Remove method of KeyedCollection takes a key.
        '
        Console.WriteLine(vbLf & "Remove(101030411)")
        weekly.Remove(101030411)

        ' The Insert method, inherited from Collection, takes an 
        ' index and an OrderItem.
        '
        Console.WriteLine(vbLf & "Insert(2, New OrderItem(...))")
        weekly.Insert(2, New OrderItem(111033401, "Nut", 10, .5))
         
        ' The default Item property is overloaded. One overload comes
        ' from KeyedCollection(Of Integer, OrderItem); that overload
        ' is read-only, and takes Integer because it retrieves by key. 
        ' The other overload comes from Collection(Of OrderItem), the 
        ' base class of KeyedCollection(Of Integer, OrderItem); it 
        ' retrieves by index, so it also takes an Integer. The compiler
        ' uses the most-derived overload, from KeyedCollection, so the
        ' only way to access SimpleOrder by index is to cast it to
        ' Collection(Of OrderItem). Otherwise the index is interpreted
        ' as a key, and KeyNotFoundException is thrown.
        '
        Dim coweekly As Collection(Of OrderItem) = weekly
        Console.WriteLine(vbLf & "coweekly(2).Description: {0}", _
            coweekly(2).Description)
 
        Console.WriteLine(vbLf & "coweekly(2) = New OrderItem(...)")
        coweekly(2) = New OrderItem(127700026, "Crank", 27, 5.98)

        Dim temp As OrderItem = coweekly(2)

        ' The IndexOf method, inherited from Collection(Of OrderItem), 
        ' takes an OrderItem instead of a key.
        ' 
        Console.WriteLine(vbLf & "IndexOf(temp): {0}", _
            weekly.IndexOf(temp))

        ' The inherited Remove method also takes an OrderItem.
        '
        Console.WriteLine(vbLf & "Remove(temp)")
        weekly.Remove(temp)

        Console.WriteLine(vbLf & "RemoveAt(0)")
        weekly.RemoveAt(0)

        ' Increase the quantity for a line item.
        Console.WriteLine(vbLf & "coweekly(1) = New OrderItem(...)")
        coweekly(1) = New OrderItem(coweekly(1).PartNumber, _
            coweekly(1).Description, coweekly(1).Quantity + 1000, _
            coweekly(1).UnitPrice)

        Display(weekly)

        Console.WriteLine()
        weekly.Clear()
    End Sub
    
    Private Shared Sub Display(ByVal order As SimpleOrder) 
        Console.WriteLine()
        For Each item As OrderItem In  order
            Console.WriteLine(item)
        Next item
    End Sub

    Private Shared Sub ChangedHandler(ByVal source As Object, _
        ByVal e As SimpleOrderChangedEventArgs)

        Dim item As OrderItem = e.ChangedItem

        If e.ChangeType = ChangeType.Replaced Then
            Dim replacement As OrderItem = e.ReplacedWith

            Console.WriteLine("{0} (quantity {1}) was replaced " & _
                "by {2}, (quantity {3}).", item.Description, _
                item.Quantity, replacement.Description, replacement.Quantity)

        ElseIf e.ChangeType = ChangeType.Cleared Then
            Console.WriteLine("The order list was cleared.")

        Else
            Console.WriteLine("{0} (quantity {1}) was {2}.", _
                item.Description, item.Quantity, e.ChangeType)
        End If
    End Sub
End Class

' This class represents a simple line item in an order. All the 
' values are immutable except quantity.
' 
Public Class OrderItem
    
    Private _partNumber As Integer
    Private _description As String
    Private _unitPrice As Double
    Private _quantity As Integer

    Public ReadOnly Property PartNumber As Integer
        Get
            Return _partNumber
        End Get
    End Property

    Public ReadOnly Property Description As String
        Get
            Return _description
        End Get
    End Property

    Public ReadOnly Property UnitPrice As Double
        Get
            Return _unitPrice
        End Get
    End Property
    
    Public ReadOnly Property Quantity() As Integer 
        Get
            Return _quantity
        End Get
    End Property
    
    Public Sub New(ByVal partNumber As Integer, _
                   ByVal description As String, _
                   ByVal quantity As Integer, _
                   ByVal unitPrice As Double) 
        _partNumber = partNumber
        _description = description
        _quantity = quantity
        _unitPrice = unitPrice
    End Sub
        
    Public Overrides Function ToString() As String 
        Return String.Format( _
            "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}", _
            PartNumber, _quantity, Description, UnitPrice, _
            UnitPrice * _quantity)
    End Function
End Class

' This code example produces the following output:
'
'Widget (quantity 400) was Added.
'Sprocket (quantity 27) was Added.
'Motor (quantity 10) was Added.
'Gear (quantity 175) was Added.
'
'110072674    400 Widget       at    45.17 =  18,068.00
'110072675     27 Sprocket     at     5.30 =     143.10
'101030411     10 Motor        at   237.50 =   2,375.00
'110072684    175 Gear         at     5.17 =     904.75
'
'Contains(101030411): True
'
'weekly(101030411).Description: Motor
'
'Remove(101030411)
'Motor (quantity 10) was Removed.
'
'Insert(2, New OrderItem(...))
'Nut (quantity 10) was Added.
'
'coweekly(2).Description: Nut
'
'coweekly(2) = New OrderItem(...)
'Nut (quantity 10) was replaced by Crank, (quantity 27).
'
'IndexOf(temp): 2
'
'Remove(temp)
'Crank (quantity 27) was Removed.
'
'RemoveAt(0)
'Widget (quantity 400) was Removed.
'
'coweekly(1) = New OrderItem(...)
'Gear (quantity 175) was replaced by Gear, (quantity 1175).
'
'110072675     27 Sprocket     at     5.30 =     143.10
'110072684   1175 Gear         at     5.17 =   6,074.75
'
'The order list was cleared.

설명

클래스는 KeyedCollection<TKey,TItem> O(1)에 접근하는 O(1) 인덱싱된 검색 및 키 검색을 모두 제공합니다. 생성된 각 제네릭 형식은 추상 기본 클래스이므로 추상 형식이거나 더 정확하게 무한 추상 형식 집합입니다. 를 사용 KeyedCollection<TKey,TItem>하려면 적절한 생성된 형식에서 컬렉션 형식을 파생합니다.

클래스는 KeyedCollection<TKey,TItem> 제네릭 인터페이스를 기반으로 IList<T> 하는 컬렉션과 제네릭 인터페이스를 기반으로 IDictionary<TKey,TValue> 하는 컬렉션 간의 하이브리드입니다. 제네릭 인터페이스 KeyedCollection<TKey,TItem> 를 기반으로 하는 IList<T> 컬렉션과 마찬가지로 는 인덱싱된 항목 목록입니다. 제네릭 인터페이스 KeyedCollection<TKey,TItem> 를 기반으로 하는 IDictionary<TKey,TValue> 컬렉션과 마찬가지로 에는 각 요소와 연결된 키가 있습니다.

사전과 달리 의 KeyedCollection<TKey,TItem> 요소는 키/값 쌍이 아닙니다. 대신 전체 요소는 값이고 키는 값 내에 포함됩니다. 예를 들어 에서 파생된 KeyedCollection\<String,String> 컬렉션의 요소는 "KeyedCollection(Of String, String) John Doe Jr."일 수 있습니다. 여기서 값은 "John Doe Jr."이고 키는 "Doe"이거나 정수 키를 포함하는 직원 레코드 컬렉션은 에서 KeyedCollection\<int,Employee>파생될 수 있습니다. 추상 GetKeyForItem 메서드는 요소에서 키를 추출합니다.

기본적으로 에는 KeyedCollection<TKey,TItem> 속성을 사용하여 가져올 수 있는 조회 사전이 Dictionary 포함됩니다. 항목이 에 KeyedCollection<TKey,TItem>추가되면 항목의 키가 한 번 추출되고 더 빠른 검색을 위해 조회 사전에 저장됩니다. 이 동작은 를 만들 때 사전 만들기 임계값을 지정하여 재정의됩니다 KeyedCollection<TKey,TItem>. 조회 사전은 요소 수가 해당 임계값을 처음 초과할 때 만들어집니다. -1을 임계값으로 지정하면 조회 사전이 만들어지지 않습니다.

참고

내부 조회 사전을 사용하는 경우 가 참조 형식인 경우 컬렉션의 모든 항목에 대한 참조를 포함하거나 가 값 형식인 경우 TItemTItem 컬렉션에 있는 모든 항목의 복사본을 포함합니다. 따라서 가 값 형식인 경우 TItem 조회 사전을 사용하는 것이 적절하지 않을 수 있습니다.

속성을 사용하여 Item[] 인덱스 또는 키로 항목에 액세스할 수 있습니다. 키 없이 항목을 추가할 수 있지만 이후에는 인덱스에서만 이러한 항목에 액세스할 수 있습니다.

생성자

KeyedCollection<TKey,TItem>()

기본 같음 비교자를 사용하는 KeyedCollection<TKey,TItem> 클래스의 새 인스턴스를 초기화합니다.

KeyedCollection<TKey,TItem>(IEqualityComparer<TKey>)

지정된 같음 비교자를 사용하는 KeyedCollection<TKey,TItem> 클래스의 새 인스턴스를 초기화합니다.

KeyedCollection<TKey,TItem>(IEqualityComparer<TKey>, Int32)

지정된 같음 비교자를 사용하고 지정된 임계값이 초과되면 조회 사전을 만드는 KeyedCollection<TKey,TItem> 클래스의 새 인스턴스를 초기화합니다.

속성

Comparer

컬렉션에 있는 키의 같음 여부를 확인하는 데 사용되는 제네릭 같음 비교자를 가져옵니다.

Count

Collection<T>에 실제로 포함된 요소의 수를 가져옵니다.

(다음에서 상속됨 Collection<T>)
Dictionary

KeyedCollection<TKey,TItem>의 조회 사전을 가져옵니다.

Item[Int32]

지정한 인덱스에 있는 요소를 가져오거나 설정합니다.

(다음에서 상속됨 Collection<T>)
Item[TKey]

지정된 키를 가진 요소를 가져옵니다.

Items

IList<T>을 둘러싸는 Collection<T> 래퍼를 가져옵니다.

(다음에서 상속됨 Collection<T>)

메서드

Add(T)

개체를 Collection<T>의 끝 부분에 추가합니다.

(다음에서 상속됨 Collection<T>)
ChangeItemKey(TItem, TKey)

조회 사전의 지정된 요소와 연결된 키를 변경합니다.

Clear()

Collection<T>에서 요소를 모두 제거합니다.

(다음에서 상속됨 Collection<T>)
ClearItems()

KeyedCollection<TKey,TItem>에서 요소를 모두 제거합니다.

Contains(TKey)

컬렉션에 지정된 키를 가진 요소가 포함된지를 확인합니다.

CopyTo(T[], Int32)

대상 배열의 지정된 인덱스에서 시작하여 전체 Collection<T>을 호환되는 1차원 Array에 복사합니다.

(다음에서 상속됨 Collection<T>)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

Collection<T>를 반복하는 열거자를 반환합니다.

(다음에서 상속됨 Collection<T>)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetKeyForItem(TItem)

파생 클래스에서 구현되면 지정된 요소에서 키를 추출합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IndexOf(T)

지정된 개체를 검색하고, 전체 Collection<T>에서 처음으로 검색한 개체의 인덱스(0부터 시작)를 반환합니다.

(다음에서 상속됨 Collection<T>)
Insert(Int32, T)

Collection<T>의 지정된 인덱스에 요소를 삽입합니다.

(다음에서 상속됨 Collection<T>)
InsertItem(Int32, T)

Collection<T>의 지정된 인덱스에 요소를 삽입합니다.

(다음에서 상속됨 Collection<T>)
InsertItem(Int32, TItem)

KeyedCollection<TKey,TItem>의 지정된 인덱스에 요소를 삽입합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Remove(TKey)

KeyedCollection<TKey,TItem>에서 지정한 키를 가지는 요소를 제거합니다.

RemoveAt(Int32)

Collection<T>의 지정된 인덱스에 있는 요소를 제거합니다.

(다음에서 상속됨 Collection<T>)
RemoveItem(Int32)

KeyedCollection<TKey,TItem>의 지정된 인덱스에 있는 요소를 제거합니다.

SetItem(Int32, T)

지정된 인덱스에 있는 요소를 바꿉니다.

(다음에서 상속됨 Collection<T>)
SetItem(Int32, TItem)

지정된 인덱스에 있는 항목을 지정된 항목으로 바꿉니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
TryGetValue(TKey, TItem)

지정된 키를 사용하여 컬렉션에서 항목을 가져오려고 시도합니다.

명시적 인터페이스 구현

ICollection.CopyTo(Array, Int32)

특정 ICollection 인덱스부터 시작하여 Array의 요소를 Array에 복사합니다.

(다음에서 상속됨 Collection<T>)
ICollection.IsSynchronized

ICollection에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Collection<T>)
ICollection.SyncRoot

ICollection에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

(다음에서 상속됨 Collection<T>)
ICollection<T>.IsReadOnly

ICollection<T>가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Collection<T>)
IEnumerable.GetEnumerator()

컬렉션을 반복하는 열거자를 반환합니다.

(다음에서 상속됨 Collection<T>)
IList.Add(Object)

IList에 항목을 추가합니다.

(다음에서 상속됨 Collection<T>)
IList.Contains(Object)

IList에 특정 값이 들어 있는지 여부를 확인합니다.

(다음에서 상속됨 Collection<T>)
IList.IndexOf(Object)

IList에서 특정 항목의 인덱스를 결정합니다.

(다음에서 상속됨 Collection<T>)
IList.Insert(Int32, Object)

항목을 IList의 지정한 인덱스에 삽입합니다.

(다음에서 상속됨 Collection<T>)
IList.IsFixedSize

IList의 크기가 고정되어 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Collection<T>)
IList.IsReadOnly

IList가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Collection<T>)
IList.Item[Int32]

지정한 인덱스에 있는 요소를 가져오거나 설정합니다.

(다음에서 상속됨 Collection<T>)
IList.Remove(Object)

IList에서 맨 처음 발견되는 특정 개체를 제거합니다.

(다음에서 상속됨 Collection<T>)

확장 메서드

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

FrozenDictionary<TKey,TValue> 지정된 키 선택기 함수에 따라 에서 IEnumerable<T> 을 만듭니다.

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

지정된 키 선택기와 요소 선택기 함수에 따라 FrozenDictionary<TKey,TValue>을 사용하여 IEnumerable<T>를 만듭니다.

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

지정된 값을 사용하여 FrozenSet<T> 을 만듭니다.

AsReadOnly<T>(IList<T>)

지정된 목록에 대한 읽기 전용 ReadOnlyCollection<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>)

제네릭 매개 변수 TDataTable인 지정된 입력 DataRow 개체를 사용하여 IEnumerable<T> 개체의 복사본이 들어 있는 DataRow을 반환합니다.

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

제네릭 매개 변수 TDataRow인 지정된 입력 DataTable 개체를 사용하여 IEnumerable<T> 개체를 지정된 DataRow에 복사합니다.

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

제네릭 매개 변수 TDataRow인 지정된 입력 DataTable 개체를 사용하여 IEnumerable<T> 개체를 지정된 DataRow에 복사합니다.

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>>)

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Decimal 값 시퀀스의 평균을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Double 값 시퀀스의 평균을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Int32 값 시퀀스의 평균을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Int64 값 시퀀스의 평균을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable 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>)

두 시퀀스를 연결합니다.

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>)

지정된 시퀀스에서 특정 조건에 맞는 요소 수를 나타내는 숫자를 반환합니다.

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

키가 값에 포함되어 있는 컬렉션에 대한 추상 기본 클래스를 제공합니다.

DefaultIfEmpty<TSource>(IEnumerable<TSource>)

지정된 시퀀스의 요소를 반환하거나, 시퀀스가 비어 있으면 형식 매개 변수의 기본값을 반환합니다.

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

지정된 시퀀스의 요소를 반환하거나, 시퀀스가 비어 있으면 singleton 컬렉션의 지정된 값을 반환합니다.

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>)

기본 같음 비교자로 값을 비교하여 두 시퀀스의 차집합을 구합니다.

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

지정된 IEqualityComparer<T>로 값을 비교하여 두 시퀀스의 차집합을 구합니다.

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

지정된 키 선택기 함수에 따라 두 시퀀스의 집합 차이를 생성합니다.

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

지정된 키 선택기 함수에 따라 두 시퀀스의 집합 차이를 생성합니다.

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>)

키가 같은지 여부에 따라 두 시퀀스의 요소를 연관시키고 결과를 그룹화합니다. 기본 같음 비교자를 사용하여 키를 비교합니다.

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

키가 같은지 여부에 따라 두 시퀀스의 요소를 연관시키고 결과를 그룹화합니다. 지정된 IEqualityComparer<T>를 사용하여 키를 비교합니다.

Index<TSource>(IEnumerable<TSource>)

키가 값에 포함되어 있는 컬렉션에 대한 추상 기본 클래스를 제공합니다.

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

기본 같음 비교자로 값을 비교하여 두 시퀀스의 교집합을 구합니다.

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

지정된 IEqualityComparer<T>로 값을 비교하여 두 시퀀스의 교집합을 구합니다.

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

지정된 키 선택기 함수에 따라 두 시퀀스의 집합 교집합을 생성합니다.

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

지정된 키 선택기 함수에 따라 두 시퀀스의 집합 교집합을 생성합니다.

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

일치하는 키를 기준으로 두 시퀀스의 요소를 연관시킵니다. 기본 같음 비교자를 사용하여 키를 비교합니다.

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

일치하는 키를 기준으로 두 시퀀스의 요소를 연관시킵니다. 지정된 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>>)

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최대 nullable Decimal 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최대 nullable Double 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최대 nullable Int32 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최대 nullable Int64 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최대 nullable 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>>)

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최소 nullable Decimal 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최소 nullable Double 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최소 nullable Int32 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최소 nullable Int64 값을 반환합니다.

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

시퀀스의 각 요소에 대해 변형 함수를 호출하고 최소 nullable 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>에 투영하고 결과 시퀀스를 단일 시퀀스로 평면화합니다.

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

시퀀스의 각 요소를 IEnumerable<T>에 투영하고 결과 시퀀스를 단일 시퀀스로 평면화합니다. 각 소스 요소의 인덱스는 해당 요소의 투영된 폼에 사용됩니다.

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

시퀀스의 각 요소를 IEnumerable<T>로 투영하고, 결과 시퀀스를 단일 시퀀스로 평면화한 다음 포함된 각 요소에 대해 결과 선택기 함수를 호출합니다.

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

시퀀스의 각 요소를 IEnumerable<T>로 투영하고, 결과 시퀀스를 단일 시퀀스로 평면화한 다음 포함된 각 요소에 대해 결과 선택기 함수를 호출합니다. 각 소스 요소의 인덱스는 해당 요소의 투영된 중간 폼에 사용됩니다.

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

해당 형식에 대한 기본 같음 비교자를 통해 요소를 비교하여 두 시퀀스가 서로 같은지 확인합니다.

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

지정된 IEqualityComparer<T>를 통해 요소를 비교하여 두 시퀀스가 서로 같은지 확인합니다.

Single<TSource>(IEnumerable<TSource>)

시퀀스의 유일한 요소를 반환하고, 시퀀스에 요소가 정확히 하나 들어 있지 않으면 예외를 throw합니다.

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

시퀀스에서 지정된 조건에 맞는 유일한 요소를 반환하고, 이러한 요소가 둘 이상 있으면 예외를 throw합니다.

SingleOrDefault<TSource>(IEnumerable<TSource>)

시퀀스의 유일한 요소를 반환하거나 시퀀스가 비어 있으면 기본값을 반환합니다. 시퀀스에 요소가 둘 이상 있으면 예외를 throw합니다.

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

시퀀스의 유일한 요소 또는 시퀀스가 비어 있는 경우 지정된 기본값을 반환합니다. 시퀀스에 요소가 두 개 이상 있는 경우 이 메서드는 예외를 throw합니다.

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

시퀀스에서 지정된 조건에 맞는 유일한 요소를 반환하거나 이러한 요소가 없으면 기본값을 반환합니다. 조건에 맞는 요소가 둘 이상 있으면 예외를 throw합니다.

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

지정된 조건을 충족하는 시퀀스의 유일한 요소 또는 이러한 요소가 없는 경우 지정된 기본값을 반환합니다. 이 메서드는 둘 이상의 요소가 조건을 충족하는 경우 예외를 throw합니다.

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>>)

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Decimal 값 시퀀스의 합을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Double 값 시퀀스의 합을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Int32 값 시퀀스의 합을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable Int64 값 시퀀스의 합을 계산합니다.

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

입력 시퀀스의 각 요소에 대해 변형 함수를 호출하여 가져온 nullable 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>)

지정된 키 선택기 함수에 따라 Dictionary<TKey,TValue>을 사용하여 IEnumerable<T>를 만듭니다.

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

지정된 키 선택기 함수와 키 비교자에 따라 Dictionary<TKey,TValue>을 사용하여 IEnumerable<T>를 만듭니다.

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

지정된 키 선택기와 요소 선택기 함수에 따라 Dictionary<TKey,TValue>을 사용하여 IEnumerable<T>를 만듭니다.

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

지정된 키 선택기 함수, 비교자 및 요소 선택기 함수에 따라 Dictionary<TKey,TValue>을 사용하여 IEnumerable<T>를 만듭니다.

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>)

지정된 키 선택기 함수에 따라 Lookup<TKey,TElement>을 사용하여 IEnumerable<T>를 만듭니다.

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

지정된 키 선택기 함수와 키 비교자에 따라 Lookup<TKey,TElement>을 사용하여 IEnumerable<T>를 만듭니다.

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

지정된 키 선택기와 요소 선택기 함수에 따라 Lookup<TKey,TElement>을 사용하여 IEnumerable<T>를 만듭니다.

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

지정된 키 선택기 함수, 비교자 및 요소 선택기 함수에 따라 Lookup<TKey,TElement>을 사용하여 IEnumerable<T>을 만듭니다.

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

열거형을 강제하지 않고 시퀀스의 요소 수를 확인하려고 시도합니다.

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

기본 같음 비교자를 사용하여 두 시퀀스의 합집합을 구합니다.

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

지정된 IEqualityComparer<T>를 사용하여 두 시퀀스의 합집합을 구합니다.

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

지정된 키 선택기 함수에 따라 두 시퀀스의 집합 결합을 생성합니다.

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

지정된 키 선택기 함수에 따라 두 시퀀스의 집합 결합을 생성합니다.

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

조건자에 따라 값의 시퀀스를 필터링합니다.

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

조건자에 따라 값의 시퀀스를 필터링합니다. 조건자 함수의 논리에 각 요소의 인덱스가 사용됩니다.

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

지정된 두 시퀀스의 요소를 사용하여 튜플 시퀀스를 생성합니다.

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

지정된 세 시퀀스의 요소를 사용하여 튜플 시퀀스를 생성합니다.

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

지정된 함수를 두 시퀀스의 해당 요소에 적용하여 결과 시퀀스를 만듭니다.

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>)

부모 노드에서 소스 컬렉션의 모든 노드를 제거합니다.

적용 대상

추가 정보