SortedList Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a collection of key/value pairs that are sorted by key based on the associated IComparer
generic
public ref class SortedList : System::Collections::Generic::ICollection>, System::Collections::Generic::IDictionary, System::Collections::Generic::IEnumerable>, System::Collections::Generic::IReadOnlyCollection>, System::Collections::Generic::IReadOnlyDictionary, System::Collections::IDictionary
generic
public ref class SortedList : System::Collections::Generic::ICollection>, System::Collections::Generic::IDictionary, System::Collections::Generic::IEnumerable>, System::Collections::IDictionary
public class SortedList : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.IDictionary
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class SortedList : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IDictionary
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class SortedList : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.IDictionary
type SortedList<'Key, 'Value> = class
interface ICollection>
interface seq>
interface IEnumerable
interface IDictionary<'Key, 'Value>
interface IReadOnlyCollection>
interface IReadOnlyDictionary<'Key, 'Value>
interface ICollection
interface IDictionary
[]
[]
type SortedList<'Key, 'Value> = class
interface IDictionary<'Key, 'Value>
interface ICollection>
interface seq>
interface IDictionary
interface ICollection
interface IEnumerable
[]
[]
type SortedList<'Key, 'Value> = class
interface IDictionary<'Key, 'Value>
interface ICollection>
interface seq>
interface IEnumerable
interface IDictionary
interface ICollection
interface IReadOnlyDictionary<'Key, 'Value>
interface IReadOnlyCollection>
Public Class SortedList(Of TKey, TValue)
Implements ICollection(Of KeyValuePair(Of TKey, TValue)), IDictionary, IDictionary(Of TKey, TValue), IEnumerable(Of KeyValuePair(Of TKey, TValue)), IReadOnlyCollection(Of KeyValuePair(Of TKey, TValue)), IReadOnlyDictionary(Of TKey, TValue)
Public Class SortedList(Of TKey, TValue)
Implements ICollection(Of KeyValuePair(Of TKey, TValue)), IDictionary, IDictionary(Of TKey, TValue), IEnumerable(Of KeyValuePair(Of TKey, TValue))
Type Parameters
- TKey
The type of keys in the collection.
- TValue
The type of values in the collection.
- Inheritance
-
SortedList
- Derived
- Attributes
- Implements
Examples
The following code example creates an empty SortedList
The example uses the Item[] property (the indexer in C#) to retrieve values, demonstrating that a KeyNotFoundException is thrown when a requested key is not present, and showing that the value associated with a key can be replaced.
The example shows how to use the TryGetValue method as a more efficient way to retrieve values if a program often must try key values that are not in the sorted list, and it shows how to use the ContainsKey method to test whether a key exists before calling the Add method.
The example shows how to enumerate the keys and values in the sorted list and how to enumerate the keys and values alone using the Keys property and the Values property.
Finally, the example demonstrates the Remove method.
using System;
using System.Collections.Generic;
public class Example
{
public static void Main()
{
// Create a new sorted list of strings, with string
// keys.
SortedList openWith =
new SortedList();
// Add some elements to the list. There are no
// duplicate keys, but some of the values are duplicates.
openWith.Add("txt", "notepad.exe");
openWith.Add("bmp", "paint.exe");
openWith.Add("dib", "paint.exe");
openWith.Add("rtf", "wordpad.exe");
// The Add method throws an exception if the new key is
// already in the list.
try
{
openWith.Add("txt", "winword.exe");
}
catch (ArgumentException)
{
Console.WriteLine("An element with Key = \"txt\" already exists.");
}
// The Item property is another name for the indexer, so you
// can omit its name when accessing elements.
Console.WriteLine("For key = \"rtf\", value = {0}.",
openWith["rtf"]);
// The indexer can be used to change the value associated
// with a key.
openWith["rtf"] = "winword.exe";
Console.WriteLine("For key = \"rtf\", value = {0}.",
openWith["rtf"]);
// If a key does not exist, setting the indexer for that key
// adds a new key/value pair.
openWith["doc"] = "winword.exe";
// The indexer throws an exception if the requested key is
// not in the list.
try
{
Console.WriteLine("For key = \"tif\", value = {0}.",
openWith["tif"]);
}
catch (KeyNotFoundException)
{
Console.WriteLine("Key = \"tif\" is not found.");
}
// When a program often has to try keys that turn out not to
// be in the list, TryGetValue can be a more efficient
// way to retrieve values.
string value = "";
if (openWith.TryGetValue("tif", out value))
{
Console.WriteLine("For key = \"tif\", value = {0}.", value);
}
else
{
Console.WriteLine("Key = \"tif\" is not found.");
}
// ContainsKey can be used to test keys before inserting
// them.
if (!openWith.ContainsKey("ht"))
{
openWith.Add("ht", "hypertrm.exe");
Console.WriteLine("Value added for key = \"ht\": {0}",
openWith["ht"]);
}
// When you use foreach to enumerate list elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine();
foreach( KeyValuePair kvp in openWith )
{
Console.WriteLine("Key = {0}, Value = {1}",
kvp.Key, kvp.Value);
}
// To get the values alone, use the Values property.
IList ilistValues = openWith.Values;
// The elements of the list are strongly typed with the
// type that was specified for the SortedList values.
Console.WriteLine();
foreach( string s in ilistValues )
{
Console.WriteLine("Value = {0}", s);
}
// The Values property is an efficient way to retrieve
// values by index.
Console.WriteLine("\nIndexed retrieval using the Values " +
"property: Values[2] = {0}", openWith.Values[2]);
// To get the keys alone, use the Keys property.
IList ilistKeys = openWith.Keys;
// The elements of the list are strongly typed with the
// type that was specified for the SortedList keys.
Console.WriteLine();
foreach( string s in ilistKeys )
{
Console.WriteLine("Key = {0}", s);
}
// The Keys property is an efficient way to retrieve
// keys by index.
Console.WriteLine("\nIndexed retrieval using the Keys " +
"property: Keys[2] = {0}", openWith.Keys[2]);
// Use the Remove method to remove a key/value pair.
Console.WriteLine("\nRemove(\"doc\")");
openWith.Remove("doc");
if (!openWith.ContainsKey("doc"))
{
Console.WriteLine("Key \"doc\" is not found.");
}
}
}
/* This code example produces the following output:
An element with Key = "txt" already exists.
For key = "rtf", value = wordpad.exe.
For key = "rtf", value = winword.exe.
Key = "tif" is not found.
Key = "tif" is not found.
Value added for key = "ht": hypertrm.exe
Key = bmp, Value = paint.exe
Key = dib, Value = paint.exe
Key = doc, Value = winword.exe
Key = ht, Value = hypertrm.exe
Key = rtf, Value = winword.exe
Key = txt, Value = notepad.exe
Value = paint.exe
Value = paint.exe
Value = winword.exe
Value = hypertrm.exe
Value = winword.exe
Value = notepad.exe
Indexed retrieval using the Values property: Values[2] = winword.exe
Key = bmp
Key = dib
Key = doc
Key = ht
Key = rtf
Key = txt
Indexed retrieval using the Keys property: Keys[2] = doc
Remove("doc")
Key "doc" is not found.
*/
Imports System.Collections.Generic
Public Class Example
Public Shared Sub Main()
' Create a new sorted list of strings, with string
' keys.
Dim openWith As New SortedList(Of String, String)
' Add some elements to the list. There are no
' duplicate keys, but some of the values are duplicates.
openWith.Add("txt", "notepad.exe")
openWith.Add("bmp", "paint.exe")
openWith.Add("dib", "paint.exe")
openWith.Add("rtf", "wordpad.exe")
' The Add method throws an exception if the new key is
' already in the list.
Try
openWith.Add("txt", "winword.exe")
Catch
Console.WriteLine("An element with Key = ""txt"" already exists.")
End Try
' The Item property is the default property, so you
' can omit its name when accessing elements.
Console.WriteLine("For key = ""rtf"", value = {0}.", _
openWith("rtf"))
' The default Item property can be used to change the value
' associated with a key.
openWith("rtf") = "winword.exe"
Console.WriteLine("For key = ""rtf"", value = {0}.", _
openWith("rtf"))
' If a key does not exist, setting the default Item property
' for that key adds a new key/value pair.
openWith("doc") = "winword.exe"
' The default Item property throws an exception if the requested
' key is not in the list.
Try
Console.WriteLine("For key = ""tif"", value = {0}.", _
openWith("tif"))
Catch
Console.WriteLine("Key = ""tif"" is not found.")
End Try
' When a program often has to try keys that turn out not to
' be in the list, TryGetValue can be a more efficient
' way to retrieve values.
Dim value As String = ""
If openWith.TryGetValue("tif", value) Then
Console.WriteLine("For key = ""tif"", value = {0}.", value)
Else
Console.WriteLine("Key = ""tif"" is not found.")
End If
' ContainsKey can be used to test keys before inserting
' them.
If Not openWith.ContainsKey("ht") Then
openWith.Add("ht", "hypertrm.exe")
Console.WriteLine("Value added for key = ""ht"": {0}", _
openWith("ht"))
End If
' When you use foreach to enumerate list elements,
' the elements are retrieved as KeyValuePair objects.
Console.WriteLine()
For Each kvp As KeyValuePair(Of String, String) In openWith
Console.WriteLine("Key = {0}, Value = {1}", _
kvp.Key, kvp.Value)
Next kvp
' To get the values alone, use the Values property.
Dim ilistValues As IList(Of String) = openWith.Values
' The elements of the list are strongly typed with the
' type that was specified for the SortedList values.
Console.WriteLine()
For Each s As String In ilistValues
Console.WriteLine("Value = {0}", s)
Next s
' The Values property is an efficient way to retrieve
' values by index.
Console.WriteLine(vbLf & "Indexed retrieval using the " & _
"Values property: Values(2) = {0}", openWith.Values(2))
' To get the keys alone, use the Keys property.
Dim ilistKeys As IList(Of String) = openWith.Keys
' The elements of the list are strongly typed with the
' type that was specified for the SortedList keys.
Console.WriteLine()
For Each s As String In ilistKeys
Console.WriteLine("Key = {0}", s)
Next s
' The Keys property is an efficient way to retrieve
' keys by index.
Console.WriteLine(vbLf & "Indexed retrieval using the " & _
"Keys property: Keys(2) = {0}", openWith.Keys(2))
' Use the Remove method to remove a key/value pair.
Console.WriteLine(vbLf + "Remove(""doc"")")
openWith.Remove("doc")
If Not openWith.ContainsKey("doc") Then
Console.WriteLine("Key ""doc"" is not found.")
End If
End Sub
End Class
' This code example produces the following output:
'
'An element with Key = "txt" already exists.
'For key = "rtf", value = wordpad.exe.
'For key = "rtf", value = winword.exe.
'Key = "tif" is not found.
'Key = "tif" is not found.
'Value added for key = "ht": hypertrm.exe
'
'Key = bmp, Value = paint.exe
'Key = dib, Value = paint.exe
'Key = doc, Value = winword.exe
'Key = ht, Value = hypertrm.exe
'Key = rtf, Value = winword.exe
'Key = txt, Value = notepad.exe
'
'Value = paint.exe
'Value = paint.exe
'Value = winword.exe
'Value = hypertrm.exe
'Value = winword.exe
'Value = notepad.exe
'
'Indexed retrieval using the Values property: Values(2) = winword.exe
'
'Key = bmp
'Key = dib
'Key = doc
'Key = ht
'Key = rtf
'Key = txt
'
'Indexed retrieval using the Keys property: Keys(2) = doc
'
'Remove("doc")
'Key "doc" is not found.
'
open System
open System.Collections.Generic
// Create a new sorted list of strings, with string
// keys.
let openWith = SortedList()
// Add some elements to the list. There are no
// duplicate keys, but some of the values are duplicates.
openWith.Add("txt", "notepad.exe")
openWith.Add("bmp", "paint.exe")
openWith.Add("dib", "paint.exe")
openWith.Add("rtf", "wordpad.exe")
// The Add method throws an exception if the new key is
// already in the list.
try
openWith.Add("txt", "winword.exe");
with
| :? ArgumentException ->
printfn "An element with Key = \"txt\" already exists."
// The Item property is another name for the indexer, so you
// can omit its name when accessing elements.
printfn $"""For key = "rtf", value = {openWith["rtf"]}."""
// The indexer can be used to change the value associated
// with a key.
openWith["rtf"] <- "winword.exe"
printfn $"""For key = "rtf", value = {openWith["rtf"]}."""
// If a key does not exist, setting the indexer for that key
// adds a new key/value pair.
openWith["doc"] <- "winword.exe";
// The indexer throws an exception if the requested key is
// not in the list.
try
printfn $"""For key = "tif", value = {openWith["tif"]}."""
with
| :? KeyNotFoundException ->
printfn "Key = \"tif\" is not found."
// When a program often has to try keys that turn out not to
// be in the list, TryGetValue can be a more efficient
// way to retrieve values.
match openWith.TryGetValue("tif") with
| true, value ->
printfn "For key = \"tif\", value = {value}."
| false, _ ->
printfn "Key = \"tif\" is not found."
// ContainsKey can be used to test keys before inserting
// them.
if not (openWith.ContainsKey("ht")) then
openWith.Add("ht", "hypertrm.exe");
printfn """Value added for key = "ht": {openWith["ht"]}"""
// When you use foreach to enumerate list elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine()
for kvp in openWith do
printfn $"Key = {kvp.Key}, Value = {kvp.Value}"
// To get the values alone, use the Values property.
let ilistValues = openWith.Values;
// The elements of the list are strongly typed with the
// type that was specified for the SortedList values.
Console.WriteLine()
for s in ilistValues do
printfn $"Value = {s}"
// The Values property is an efficient way to retrieve
// values by index.
printf "\nIndexed retrieval using the Values "
printfn $"property: Values[2] = {openWith.Values[2]}"
// To get the keys alone, use the Keys property.
let ilistKeys = openWith.Keys;
// The elements of the list are strongly typed with the
// type that was specified for the SortedList keys.
Console.WriteLine()
for s in ilistKeys do
printfn $"Key = {s}"
// The Keys property is an efficient way to retrieve
// keys by index.
printf "\nIndexed retrieval using the Keys "
printfn $"property: Keys[2] = {openWith.Keys[2]}"
// Use the Remove method to remove a key/value pair.
printfn "\nRemove(\"doc\")"
openWith.Remove("doc") |> ignore
if not (openWith.ContainsKey("doc")) then
printfn "Key \"doc\" is not found."
(* This code example produces the following output:
An element with Key = "txt" already exists.
For key = "rtf", value = wordpad.exe.
For key = "rtf", value = winword.exe.
Key = "tif" is not found.
Key = "tif" is not found.
Value added for key = "ht": hypertrm.exe
Key = bmp, Value = paint.exe
Key = dib, Value = paint.exe
Key = doc, Value = winword.exe
Key = ht, Value = hypertrm.exe
Key = rtf, Value = winword.exe
Key = txt, Value = notepad.exe
Value = paint.exe
Value = paint.exe
Value = winword.exe
Value = hypertrm.exe
Value = winword.exe
Value = notepad.exe
Indexed retrieval using the Values property: Values[2] = winword.exe
Key = bmp
Key = dib
Key = doc
Key = ht
Key = rtf
Key = txt
Indexed retrieval using the Keys property: Keys[2] = doc
Remove("doc")
Key "doc" is not found.
*)
Remarks
The SortedListn) retrieval, where n is the number of elements in the dictionary. In this, it is similar to the SortedDictionaryn) retrieval. Where the two classes differ is in memory use and speed of insertion and removal:
SortedList
uses less memory than SortedDictionary . SortedDictionary
has faster insertion and removal operations for unsorted data, O(log n) as opposed to O(n) for SortedList. If the list is populated all at once from sorted data, SortedList
is faster than SortedDictionary .
Another difference between the SortedDictionary
string v = mySortedList.Values[3];
Dim v As String = mySortedList.Values(3)
let v = mySortedList.Values[3]
SortedList
Key objects must be immutable as long as they are used as keys in the SortedListnull, but a value can be, if the type of values in the list, TValue, is a reference type.
SortedListTKey implements System.IComparableTKey implements System.IComparable. If the key type TKey does not implement either interface, you can specify a System.Collections.Generic.IComparercomparer parameter.
The capacity of a SortedList
.NET Framework only: For very large SortedListenabled attribute of the configuration element to true in the run-time environment.
The foreach statement of the C# language (For Each in Visual Basic) returns an object of the type of the elements in the collection. Since the elements of the SortedList
foreach( KeyValuePair kvp in mySortedList )
{
Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
For Each kvp As KeyValuePair(Of Integer, String) In mySortedList
Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value)
Next kvp
for kvp in mySortedList do
printfn $"Key = {kvp.Key}, Value = {kvp.Value}"
The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.
Constructors
| Name | Description |
|---|---|
|
SortedList |
Initializes a new instance of the SortedList |
|
SortedList |
Initializes a new instance of the SortedList |
|
SortedList |
Initializes a new instance of the SortedList |
|
SortedList |
Initializes a new instance of the SortedList |
|
SortedList |
Initializes a new instance of the SortedList |
|
SortedList |
Initializes a new instance of the SortedList |
Properties
| Name | Description |
|---|---|
| Capacity |
Gets or sets the number of elements that the SortedList |
| Comparer |
Gets the IComparer |
| Count |
Gets the number of key/value pairs contained in the SortedList |
| Item[TKey] |
Gets or sets the value associated with the specified key. |
| Keys |
Gets a collection containing the keys in the SortedList |
| Values |
Gets a collection containing the values in the SortedList |
Methods
| Name | Description |
|---|---|
| Add(TKey, TValue) |
Adds an element with the specified key and value into the SortedList |
| Clear() |
Removes all elements from the SortedList |
| ContainsKey(TKey) |
Determines whether the SortedList |
| ContainsValue(TValue) |
Determines whether the SortedList |
| Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
| GetEnumerator() |
Returns an enumerator that iterates through the SortedList |
| GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
| GetKeyAtIndex(Int32) |
Gets the key corresponding to the specified index. |
| GetType() |
Gets the Type of the current instance. (Inherited from Object) |
| GetValueAtIndex(Int32) |
Gets the value corresponding to the specified index. |
| IndexOfKey(TKey) |
Searches for the specified key and returns the zero-based index within the entire SortedList |
| IndexOfValue(TValue) |
Searches for the specified value and returns the zero-based index of the first occurrence within the entire SortedList |
| MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
| Remove(TKey) |
Removes the element with the specified key from the SortedList |
| RemoveAt(Int32) |
Removes the element at the specified index of the SortedList |
| SetValueAtIndex(Int32, TValue) |
Updates the value corresponding to the specified index. |
| ToString() |
Returns a string that represents the current object. (Inherited from Object) |
| TrimExcess() |
Sets the capacity to the actual number of elements in the SortedList |
| TryGetValue(TKey, TValue) |
Gets the value associated with the specified key. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Copies the elements of the ICollection to an Array, starting at a particular Array index. |
| ICollection.IsSynchronized |
Gets a value indicating whether access to the ICollection is synchronized (thread safe). |
| ICollection.SyncRoot |
Gets an object that can be used to synchronize access to the ICollection. |
|
ICollection |
Adds a key/value pair to the ICollection |
|
ICollection |
Determines whether the ICollection |
|
ICollection |
Copies the elements of the ICollection |
|
ICollection |
Gets a value indicating whether the ICollection |
|
ICollection |
Removes the first occurrence of a specific key/value pair from the ICollection |
| IDictionary.Add(Object, Object) |
Adds an element with the provided key and value to the IDictionary. |
| IDictionary.Contains(Object) |
Determines whether the IDictionary contains an element with the specified key. |
| IDictionary.GetEnumerator() |
Returns an IDictionaryEnumerator for the IDictionary. |
| IDictionary.IsFixedSize |
Gets a value indicating whether the IDictionary has a fixed size. |
| IDictionary.IsReadOnly |
Gets a value indicating whether the IDictionary is read-only. |
| IDictionary.Item[Object] |
Gets or sets the element with the specified key. |
| IDictionary.Keys |
Gets an ICollection containing the keys of the IDictionary. |
| IDictionary.Remove(Object) |
Removes the element with the specified key from the IDictionary. |
| IDictionary.Values |
Gets an ICollection containing the values in the IDictionary. |
|
IDictionary |
Gets an ICollection |
|
IDictionary |
Gets an ICollection |
| IEnumerable.GetEnumerator() |
Returns an enumerator that iterates through a collection. |
|
IEnumerable |
Returns an enumerator that iterates through a collection. |
|
IReadOnlyDictionary |
Gets an enumerable collection that contains the keys in the read-only dictionary. |
|
IReadOnlyDictionary |
Gets an enumerable collection that contains the values in the read-only dictionary. |
Extension Methods
| Name | Description |
|---|---|
|
Aggregate |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value. |
|
Aggregate |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value. |
|
Aggregate |
Applies an accumulator function over a sequence. |
|
AggregateBy |
Applies an accumulator function over a sequence, grouping results by key. |
|
AggregateBy |
Applies an accumulator function over a sequence, grouping results by key. |
|
All |
Determines whether all elements of a sequence satisfy a condition. |
|
Ancestors |
Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection. |
|
Ancestors |
Returns a collection of elements that contains the ancestors of every node in the source collection. |
|
Any |
Determines whether any element of a sequence satisfies a condition. |
|
Any |
Determines whether a sequence contains any elements. |
|
Append |
Appends a value to the end of the sequence. |
|
AsEnumerable |
Returns the input typed as IEnumerable |
| AsParallel(IEnumerable) |
Enables parallelization of a query. |
|
AsParallel |
Enables parallelization of a query. |
| AsQueryable(IEnumerable) |
Converts an IEnumerable to an IQueryable. |
|
AsQueryable |
Converts a generic IEnumerable |
|
AsReadOnly |
Returns a read-only ReadOnlyDictionary |
|
Average |
Computes the average of a sequence of Decimal values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of Double values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of Int32 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of nullable Double values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of nullable Single values that are obtained by invoking a transform function on each element of the input sequence. |
|
Average |
Computes the average of a sequence of Single values that are obtained by invoking a transform function on each element of the input sequence. |
|
Cast |
Casts the elements of an IEnumerable to the specified type. |
|
Chunk |
Splits the elements of a sequence into chunks of size at most |
|
Concat |
Concatenates two sequences. |
|
Contains |
Determines whether a sequence contains a specified element by using a specified IEqualityComparer |
|
Contains |
Determines whether a sequence contains a specified element by using the default equality comparer. |
|
CopyToDataTable |
Copies DataRow objects to the specified DataTable, given an input IEnumerable |
|
CopyToDataTable |
Copies DataRow objects to the specified DataTable, given an input IEnumerable |
|
CopyToDataTable |
Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable |
|
Count |
Returns a number that represents how many elements in the specified sequence satisfy a condition. |
|
Count |
Returns the number of elements in a sequence. |
|
CountBy |
Returns the count of elements in the source sequence grouped by key. |
|
DefaultIfEmpty |
Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty. |
|
DefaultIfEmpty |
Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty. |
|
DescendantNodes |
Returns a collection of the descendant nodes of every document and element in the source collection. |
|
Descendants |
Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection. |
|
Descendants |
Returns a collection of elements that contains the descendant elements of every element and document in the source collection. |
|
Distinct |
Returns distinct elements from a sequence by using a specified IEqualityComparer |
|
Distinct |
Returns distinct elements from a sequence by using the default equality comparer to compare values. |
|
DistinctBy |
Returns distinct elements from a sequence according to a specified key selector function and using a specified comparer to compare keys. |
|
DistinctBy |
Returns distinct elements from a sequence according to a specified key selector function. |
|
ElementAt |
Returns the element at a specified index in a sequence. |
|
ElementAt |
Returns the element at a specified index in a sequence. |
|
ElementAtOrDefault |
Returns the element at a specified index in a sequence or a default value if the index is out of range. |
|
ElementAtOrDefault |
Returns the element at a specified index in a sequence or a default value if the index is out of range. |
|
Elements |
Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection. |
|
Elements |
Returns a collection of the child elements of every element and document in the source collection. |
|
Except |
Produces the set difference of two sequences by using the specified IEqualityComparer |
|
Except |
Produces the set difference of two sequences by using the default equality comparer to compare values. |
|
ExceptBy |
Produces the set difference of two sequences according to a specified key selector function. |
|
ExceptBy |
Produces the set difference of two sequences according to a specified key selector function. |
|
First |
Returns the first element in a sequence that satisfies a specified condition. |
|
First |
Returns the first element of a sequence. |
|
FirstOrDefault |
Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found. |
|
FirstOrDefault |
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. |
|
FirstOrDefault |
Returns the first element of a sequence, or a specified default value if the sequence contains no elements. |
|
FirstOrDefault |
Returns the first element of a sequence, or a default value if the sequence contains no elements. |
|
FullJoin |
|
|
FullJoin |
|
|
GetValueOrDefault |
Tries to get the value associated with the specified |
|
GetValueOrDefault |
Tries to get the value associated with the specified |
|
GroupBy |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function. |
|
GroupBy |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. |
|
GroupBy |
Groups the elements of a sequence according to a key selector function. The keys are compared by using a comparer and each group's elements are projected by using a specified function. |
|
GroupBy |
Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function. |
|
GroupBy |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The keys are compared by using a specified comparer. |
|
GroupBy |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. |
|
GroupBy |
Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer. |
|
GroupBy |
Groups the elements of a sequence according to a specified key selector function. |
|
GroupJoin |
Correlates the elements of two sequences based on key equality and groups the results. A specified IEqualityComparer |
|
GroupJoin |
Correlates the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys. |
|
GroupJoin |
|
|
Index |
Returns an enumerable that incorporates the element's index into a tuple. |
|
InDocumentOrder |
Returns a collection of nodes that contains all nodes in the source collection, sorted in document order. |
|
Intersect |
Produces the set intersection of two sequences by using the specified IEqualityComparer |
|
Intersect |
Produces the set intersection of two sequences by using the default equality comparer to compare values. |
|
IntersectBy |
Produces the set intersection of two sequences according to a specified key selector function. |
|
IntersectBy |
Produces the set intersection of two sequences according to a specified key selector function. |
|
Join |
Correlates the elements of two sequences based on matching keys. A specified IEqualityComparer |
|
Join |
Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys. |
|
Join |
|
|
Last |
Returns the last element of a sequence that satisfies a specified condition. |
|
Last |
Returns the last element of a sequence. |
|
LastOrDefault |
Returns the last element of a sequence that satisfies a condition, or a specified default value if no such element is found. |
|
LastOrDefault |
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. |
|
LastOrDefault |
Returns the last element of a sequence, or a specified default value if the sequence contains no elements. |
|
LastOrDefault |
Returns the last element of a sequence, or a default value if the sequence contains no elements. |
|
LeftJoin |
Correlates the elements of two sequences based on matching keys. A specified IEqualityComparer |
|
LeftJoin |
Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys. |
|
LeftJoin |
|
|
LongCount |
Returns an Int64 that represents how many elements in a sequence satisfy a condition. |
|
LongCount |
Returns an Int64 that represents the total number of elements in a sequence. |
|
Max |
Invokes a transform function on each element of a generic sequence and returns the maximum resulting value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum Decimal value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum Double value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum Int32 value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum Int64 value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum nullable Decimal value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum nullable Double value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum nullable Int32 value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum nullable Int64 value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum nullable Single value. |
|
Max |
Invokes a transform function on each element of a sequence and returns the maximum Single value. |
|
Max |
Returns the maximum value in a generic sequence. |
|
Max |
Returns the maximum value in a generic sequence. |
|
MaxBy |
Returns the maximum value in a generic sequence according to a specified key selector function and key comparer. |
|
MaxBy |
Returns the maximum value in a generic sequence according to a specified key selector function. |
|
Min |
Invokes a transform function on each element of a generic sequence and returns the minimum resulting value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum Decimal value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum Double value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum Int32 value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum Int64 value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum nullable Decimal value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum nullable Double value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum nullable Int32 value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum nullable Int64 value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum nullable Single value. |
|
Min |
Invokes a transform function on each element of a sequence and returns the minimum Single value. |
|
Min |
Returns the minimum value in a generic sequence. |
|
Min |
Returns the minimum value in a generic sequence. |
|
MinBy |
Returns the minimum value in a generic sequence according to a specified key selector function and key comparer. |
|
MinBy |
Returns the minimum value in a generic sequence according to a specified key selector function. |
|
Nodes |
Returns a collection of the child nodes of every document and element in the source collection. |
|
OfType |
Filters the elements of an IEnumerable based on a specified type. |
|
Order |
Sorts the elements of a sequence in ascending order. |
|
Order |
Sorts the elements of a sequence in ascending order. |
|
OrderBy |
Sorts the elements of a sequence in ascending order by using a specified comparer. |
|
OrderBy |
Sorts the elements of a sequence in ascending order according to a key. |
|
OrderByDescending |
Sorts the elements of a sequence in descending order by using a specified comparer. |
|
OrderByDescending |
Sorts the elements of a sequence in descending order according to a key. |
|
OrderDescending |
Sorts the elements of a sequence in descending order. |
|
OrderDescending |
Sorts the elements of a sequence in descending order. |
|
Prepend |
Adds a value to the beginning of the sequence. |
|
Remove |
Removes every node in the source collection from its parent node. |
|
Remove |
Tries to remove the value with the specified |
|
Reverse |
Inverts the order of the elements in a sequence. |
|
RightJoin |
Correlates the elements of two sequences based on matching keys. A specified IEqualityComparer |
|
RightJoin |
Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys. |
|
RightJoin |
|
|
Select |
Projects each element of a sequence into a new form by incorporating the element's index. |
|
Select |
Projects each element of a sequence into a new form. |
|
SelectMany |
Projects each element of a sequence to an IEnumerable |
|
SelectMany |
Projects each element of a sequence to an IEnumerable |
|
SelectMany |
Projects each element of a sequence to an IEnumerable |
|
SelectMany |
Projects each element of a sequence to an IEnumerable |
|
SequenceEqual |
Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer |
|
SequenceEqual |
Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type. |
|
Shuffle |
Shuffles the order of the elements of a sequence. |
|
Single |
Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. |
|
Single |
Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. |
|
SingleOrDefault |
Returns the only element of a sequence that satisfies a specified condition, or a specified default value if no such element exists; this method throws an exception if more than one element satisfies the condition. |
|
SingleOrDefault |
Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition. |
|
SingleOrDefault |
Returns the only element of a sequence, or a specified default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence. |
|
SingleOrDefault |
Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence. |
|
Skip |
Bypasses a specified number of elements in a sequence and then returns the remaining elements. |
|
SkipLast |
Returns a new enumerable collection that contains the elements from |
|
SkipWhile |
Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. |
|
SkipWhile |
Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function. |
|
Sum |
Computes the sum of the sequence of Decimal values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of Int32 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of nullable Double values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of nullable Single values that are obtained by invoking a transform function on each element of the input sequence. |
|
Sum |
Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence. |
|
Take |
Returns a specified number of contiguous elements from the start of a sequence. |
|
Take |
Returns a specified range of contiguous elements from a sequence. |
|
TakeLast |
Returns a new enumerable collection that contains the last |
|
TakeWhile |
Returns elements from a sequence as long as a specified condition is true. |
|
TakeWhile |
Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function. |
|
ToArray |
Creates an array from a IEnumerable |
|
ToAsyncEnumerable |
Converts an IEnumerable |
|
ToDictionary |
Creates a Dictionary |
|
ToDictionary |
Creates a Dictionary |
|
ToDictionary |
Creates a Dictionary |
|
ToDictionary |
Creates a Dictionary |
|
ToFrozenDictionary |
Creates a FrozenDictionary |
|
ToFrozenDictionary |
Creates a FrozenDictionary |
|
ToFrozenSet |
Creates a FrozenSet |
|
ToHashSet |
Creates a HashSet |
|
ToHashSet |
Creates a HashSet |
|
ToImmutableArray |
Creates an immutable array from the specified collection. |
|
ToImmutableDictionary |
Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key and value comparers. |
|
ToImmutableDictionary |
Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key comparer. |
|
ToImmutableDictionary |
Enumerates and transforms a sequence, and produces an immutable dictionary of its contents. |
|
ToImmutableDictionary |
Constructs an immutable dictionary based on some transformation of a sequence. |
|
ToImmutableDictionary |
Constructs an immutable dictionary from an existing collection of elements, applying a transformation function to the source keys. |
|
ToImmutableHashSet |
Enumerates a sequence, produces an immutable hash set of its contents, and uses the specified equality comparer for the set type. |
|
ToImmutableHashSet |
Enumerates a sequence and produces an immutable hash set of its contents. |
|
ToImmutableList |
Enumerates a sequence and produces an immutable list of its contents. |
|
ToImmutableSortedDictionary |
Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key and value comparers. |
|
ToImmutableSortedDictionary |
Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key comparer. |
|
ToImmutableSortedDictionary |
Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents. |
|
ToImmutableSortedSet |
Enumerates a sequence, produces an immutable sorted set of its contents, and uses the specified comparer. |
|
ToImmutableSortedSet |
Enumerates a sequence and produces an immutable sorted set of its contents. |
|
ToList |
Creates a List |
|
ToLookup |
Creates a Lookup |
|
ToLookup |
Creates a Lookup |
|
ToLookup |
Creates a Lookup |
|
ToLookup |
Creates a Lookup |
|
TryAdd |
Tries to add the specified |
|
TryGetNonEnumeratedCount |
Attempts to determine the number of elements in a sequence without forcing an enumeration. |
|
Union |
Produces the set union of two sequences by using a specified IEqualityComparer |
|
Union |
Produces the set union of two sequences by using the default equality comparer. |
|
UnionBy |
Produces the set union of two sequences according to a specified key selector function. |
|
UnionBy |
Produces the set union of two sequences according to a specified key selector function. |
|
Where |
Filters a sequence of values based on a predicate. |
|
Where |
Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function. |
|
Zip |
Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results. |
|
Zip |
Produces a sequence of tuples with elements from the three specified sequences. |
|
Zip |
Produces a sequence of tuples with elements from the two specified sequences. |
Applies to
Thread Safety
Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
A SortedList