Array Класс

Определение

Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.

public ref class Array abstract : System::Collections::IList, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
public ref class Array abstract : ICloneable, System::Collections::IList, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
public ref class Array abstract : ICloneable, System::Collections::IList
public abstract class Array : System.Collections.IList, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
public abstract class Array : ICloneable, System.Collections.IList, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
[System.Serializable]
public abstract class Array : ICloneable, System.Collections.IList
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class Array : ICloneable, System.Collections.IList
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class Array : ICloneable, System.Collections.IList, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
type Array = class
    interface ICollection
    interface IEnumerable
    interface IList
    interface IStructuralComparable
    interface IStructuralEquatable
type Array = class
    interface ICollection
    interface IEnumerable
    interface IList
    interface IStructuralComparable
    interface IStructuralEquatable
    interface ICloneable
type Array = class
    interface ICloneable
    interface IList
    interface ICollection
    interface IEnumerable
type Array = class
    interface ICloneable
    interface IList
    interface ICollection
    interface IEnumerable
    interface IStructuralComparable
    interface IStructuralEquatable
type Array = class
    interface IList
    interface ICollection
    interface IEnumerable
    interface IStructuralComparable
    interface IStructuralEquatable
type Array = class
    interface ICloneable
    interface ICollection
    interface IList
    interface IEnumerable
    interface IStructuralComparable
    interface IStructuralEquatable
Public MustInherit Class Array
Implements IList, IStructuralComparable, IStructuralEquatable
Public MustInherit Class Array
Implements ICloneable, IList, IStructuralComparable, IStructuralEquatable
Public MustInherit Class Array
Implements ICloneable, IList
Наследование
Array
Атрибуты
Реализации

Примеры

В следующем примере кода показано использование Array.Copy для копирования элементов между массивом целочисленного типа и массивом объектов типа Object.The following code example shows how Array.Copy copies elements between an array of type integer and an array of type Object.

using namespace System;

void PrintValues(array<Object^>^myArr);
void PrintValues(array<int>^myArr);
void main()
{
    // Creates and initializes a new int array and a new Object array.
    array<int>^myIntArray = { 1,2,3,4,5 };
    array<Object^>^myObjArray = { 26,27,28,29,30 };

    // Prints the initial values of both arrays.
    Console::WriteLine("Initially:");
    Console::Write("int array:   ");
    PrintValues(myIntArray);
    Console::Write("Object array:");
    PrintValues(myObjArray);

    // Copies the first two elements from the int array to the Object array.
    System::Array::Copy(myIntArray, myObjArray, 2);

    // Prints the values of the modified arrays.
    Console::WriteLine("\nAfter copying the first two elements of the int array to the Object array:");
    Console::Write("int array:   ");
    PrintValues(myIntArray);
    Console::Write("Object array:");
    PrintValues(myObjArray);

    // Copies the last two elements from the Object array to the int array.
    System::Array::Copy(myObjArray, myObjArray->GetUpperBound(0) - 1, myIntArray, myIntArray->GetUpperBound(0) - 1, 2);

    // Prints the values of the modified arrays.
    Console::WriteLine("\nAfter copying the last two elements of the Object array to the int array:");
    Console::Write("int array:   ");
    PrintValues(myIntArray);
    Console::Write("Object array:");
    PrintValues(myObjArray);
}

void PrintValues(array<Object^>^myArr)
{
    for (int i = 0; i < myArr->Length; i++)
    {
        Console::Write("\t{0}", myArr[i]);

    }
    Console::WriteLine();
}

void PrintValues(array<int>^myArr)
{
    for (int i = 0; i < myArr->Length; i++)
    {
        Console::Write("\t{0}", myArr[i]);

    }
    Console::WriteLine();
}


/*
This code produces the following output.

Initially:
int array:       1    2    3    4    5
Object array:    26    27    28    29    30
After copying the first two elements of the int array to the Object array:
int array:       1    2    3    4    5
Object array:    1    2    28    29    30
After copying the last two elements of the Object array to the int array:
int array:       1    2    3    29    30
Object array:    1    2    28    29    30
*/
using System;
public class SamplesArray
{

    public static void Main()
    {

        // Creates and initializes a new integer array and a new Object array.
        int[] myIntArray = new int[5] { 1, 2, 3, 4, 5 };
        Object[] myObjArray = new Object[5] { 26, 27, 28, 29, 30 };

        // Prints the initial values of both arrays.
        Console.WriteLine("Initially,");
        Console.Write("integer array:");
        PrintValues(myIntArray);
        Console.Write("Object array: ");
        PrintValues(myObjArray);

        // Copies the first two elements from the integer array to the Object array.
        System.Array.Copy(myIntArray, myObjArray, 2);

        // Prints the values of the modified arrays.
        Console.WriteLine("\nAfter copying the first two elements of the integer array to the Object array,");
        Console.Write("integer array:");
        PrintValues(myIntArray);
        Console.Write("Object array: ");
        PrintValues(myObjArray);

        // Copies the last two elements from the Object array to the integer array.
        System.Array.Copy(myObjArray, myObjArray.GetUpperBound(0) - 1, myIntArray, myIntArray.GetUpperBound(0) - 1, 2);

        // Prints the values of the modified arrays.
        Console.WriteLine("\nAfter copying the last two elements of the Object array to the integer array,");
        Console.Write("integer array:");
        PrintValues(myIntArray);
        Console.Write("Object array: ");
        PrintValues(myObjArray);
    }

    public static void PrintValues(Object[] myArr)
    {
        foreach (Object i in myArr)
        {
            Console.Write("\t{0}", i);
        }
        Console.WriteLine();
    }

    public static void PrintValues(int[] myArr)
    {
        foreach (int i in myArr)
        {
            Console.Write("\t{0}", i);
        }
        Console.WriteLine();
    }
}
/*
This code produces the following output.

Initially,
integer array:  1       2       3       4       5
Object array:   26      27      28      29      30

After copying the first two elements of the integer array to the Object array,
integer array:  1       2       3       4       5
Object array:   1       2       28      29      30

After copying the last two elements of the Object array to the integer array,
integer array:  1       2       3       29      30
Object array:   1       2       28      29      30
*/
Public Class SamplesArray

    Public Shared Sub Main()

        ' Creates and initializes a new integer array and a new Object array.
        Dim myIntArray() As Integer = {1, 2, 3, 4, 5}
        Dim myObjArray() As Object = {26, 27, 28, 29, 30}

        ' Prints the initial values of both arrays.
        Console.WriteLine("Initially:")
        Console.Write("integer array:")
        PrintValues(myIntArray)
        Console.Write("Object array: ")
        PrintValues(myObjArray)

        ' Copies the first two elements from the integer array to the Object array.
        System.Array.Copy(myIntArray, myObjArray, 2)

        ' Prints the values of the modified arrays.
        Console.WriteLine(ControlChars.NewLine + "After copying the first two" _
           + " elements of the integer array to the Object array:")
        Console.Write("integer array:")
        PrintValues(myIntArray)
        Console.Write("Object array: ")
        PrintValues(myObjArray)

        ' Copies the last two elements from the Object array to the integer array.
        System.Array.Copy(myObjArray, myObjArray.GetUpperBound(0) - 1, myIntArray,
           myIntArray.GetUpperBound(0) - 1, 2)

        ' Prints the values of the modified arrays.
        Console.WriteLine(ControlChars.NewLine + "After copying the last two" _
           + " elements of the Object array to the integer array:")
        Console.Write("integer array:")
        PrintValues(myIntArray)
        Console.Write("Object array: ")
        PrintValues(myObjArray)
    End Sub

    Public Overloads Shared Sub PrintValues(myArr() As Object)
        Dim i As Object
        For Each i In myArr
            Console.Write(ControlChars.Tab + "{0}", i)
        Next i
        Console.WriteLine()
    End Sub

    Public Overloads Shared Sub PrintValues(myArr() As Integer)
        Dim i As Integer
        For Each i In myArr
            Console.Write(ControlChars.Tab + "{0}", i)
        Next i
        Console.WriteLine()
    End Sub
End Class

' This code produces the following output.
' 
' Initially:
' integer array:  1       2       3       4       5
' Object array:   26      27      28      29      30
' 
' After copying the first two elements of the integer array to the Object array:
' integer array:  1       2       3       4       5
' Object array:   1       2       28      29      30
' 
' After copying the last two elements of the Object array to the integer array:
' integer array:  1       2       3       29      30
' Object array:   1       2       28      29      30

В следующем примере кода создается и инициализируется Array и отображаются его свойства и элементы.The following code example creates and initializes an Array and displays its properties and its elements.

using namespace System;
void PrintValues(Array^ myArr);
void main()
{
   // Creates and initializes a new three-dimensional Array instance of type Int32.
   Array^ myArr = Array::CreateInstance( Int32::typeid, 2, 3, 4 );
   for ( int i = myArr->GetLowerBound( 0 ); i <= myArr->GetUpperBound( 0 ); i++ )
   {
      for ( int j = myArr->GetLowerBound( 1 ); j <= myArr->GetUpperBound( 1 ); j++ )
      {
         for ( int k = myArr->GetLowerBound( 2 ); k <= myArr->GetUpperBound( 2 ); k++ )
            myArr->SetValue( (i * 100) + (j * 10) + k, i, j, k );

      }
   }
   
   // Displays the properties of the Array.
   Console::WriteLine(  "The Array instance has {0} dimension(s) and a total of {1} elements.", myArr->Rank, myArr->Length );
   Console::WriteLine(  "\tLength\tLower\tUpper" );
   for ( int i = 0; i < myArr->Rank; i++ )
   {
      Console::Write(  "{0}:\t{1}", i, myArr->GetLength( i ) );
      Console::WriteLine(  "\t{0}\t{1}", myArr->GetLowerBound( i ), myArr->GetUpperBound( i ) );

   }
   Console::WriteLine(  "The Array instance contains the following values:" );
   PrintValues( myArr );
}

void PrintValues( Array^ myArr )
{
   System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator();
   int i = 0;
   int cols = myArr->GetLength( myArr->Rank - 1 );
   while ( myEnumerator->MoveNext() )
   {
      if ( i < cols )
            i++;
      else
      {
         Console::WriteLine();
         i = 1;
      }

      Console::Write(  "\t{0}", myEnumerator->Current );
   }

   Console::WriteLine();
}

/* 
 This code produces the following output.
 
 The Array instance has 3 dimension(s) and a total of 24 elements.
     Length    Lower    Upper
 0:    2    0    1
 1:    3    0    2
 2:    4    0    3
 The Array instance contains the following values:
     0    1    2    3
     10    11    12    13
     20    21    22    23
     100    101    102    103
     110    111    112    113
     120    121    122    123
 */
// Creates and initializes a new three-dimensional Array of type Int32.
Array myArr = Array.CreateInstance(typeof(Int32), 2, 3, 4);
for (int i = myArr.GetLowerBound(0); i <= myArr.GetUpperBound(0); i++)
{
    for (int j = myArr.GetLowerBound(1); j <= myArr.GetUpperBound(1); j++)
    {
        for (int k = myArr.GetLowerBound(2); k <= myArr.GetUpperBound(2); k++)
        {
            myArr.SetValue((i * 100) + (j * 10) + k, i, j, k);
        }
    }
}

// Displays the properties of the Array.
Console.WriteLine("The Array has {0} dimension(s) and a total of {1} elements.", myArr.Rank, myArr.Length);
Console.WriteLine("\tLength\tLower\tUpper");
for (int i = 0; i < myArr.Rank; i++)
{
    Console.Write("{0}:\t{1}", i, myArr.GetLength(i));
    Console.WriteLine("\t{0}\t{1}", myArr.GetLowerBound(i), myArr.GetUpperBound(i));
}

// Displays the contents of the Array.
Console.WriteLine("The Array contains the following values:");
PrintValues(myArr);

void PrintValues(Array myArray)
{
    System.Collections.IEnumerator myEnumerator = myArray.GetEnumerator();
    int i = 0;
    int cols = myArray.GetLength(myArray.Rank - 1);
    while (myEnumerator.MoveNext())
    {
        if (i < cols)
        {
            i++;
        }
        else
        {
            Console.WriteLine();
            i = 1;
        }
        Console.Write("\t{0}", myEnumerator.Current);
    }
    Console.WriteLine();
}
// This code produces the following output.

// The Array has 3 dimension(s) and a total of 24 elements.
//     Length    Lower    Upper
// 0:  2    0    1
// 1:  3    0    2
// 2:  4    0    3
//
// The Array contains the following values:
//    0      1      2      3
//    10     11     12     13
//    20     21     22     23
//    100    101    102    103
//    110    111    112    113
//    120    121    122    123
Public Class SamplesArray2

    Public Shared Sub Main()

        ' Creates and initializes a new three-dimensional Array of
        ' type Int32.
        Dim myArr As Array = Array.CreateInstance(GetType(Int32), 2, 3, 4)
        Dim i As Integer
        For i = myArr.GetLowerBound(0) To myArr.GetUpperBound(0)
            Dim j As Integer
            For j = myArr.GetLowerBound(1) To myArr.GetUpperBound(1)
                Dim k As Integer
                For k = myArr.GetLowerBound(2) To myArr.GetUpperBound(2)
                    myArr.SetValue(i * 100 + j * 10 + k, i, j, k)
                Next k
            Next j
        Next i ' Displays the properties of the Array.
        Console.WriteLine("The Array has {0} dimension(s) and a " _
           + "total of {1} elements.", myArr.Rank, myArr.Length)
        Console.WriteLine(ControlChars.Tab + "Length" + ControlChars.Tab _
           + "Lower" + ControlChars.Tab + "Upper")
        For i = 0 To myArr.Rank - 1
            Console.Write("{0}:" + ControlChars.Tab + "{1}", i,
               myArr.GetLength(i))
            Console.WriteLine(ControlChars.Tab + "{0}" + ControlChars.Tab _
               + "{1}", myArr.GetLowerBound(i), myArr.GetUpperBound(i))
        Next i

        ' Displays the contents of the Array.
        Console.WriteLine("The Array contains the following values:")
        PrintValues(myArr)
    End Sub

    Public Shared Sub PrintValues(myArr As Array)
        Dim myEnumerator As System.Collections.IEnumerator =
           myArr.GetEnumerator()
        Dim i As Integer = 0
        Dim cols As Integer = myArr.GetLength(myArr.Rank - 1)
        While myEnumerator.MoveNext()
            If i < cols Then
                i += 1
            Else
                Console.WriteLine()
                i = 1
            End If
            Console.Write(ControlChars.Tab + "{0}", myEnumerator.Current)
        End While
        Console.WriteLine()
    End Sub
End Class

' This code produces the following output.
' 
' The Array has 3 dimension(s) and a total of 24 elements.
'     Length    Lower    Upper
' 0:    2    0    1
' 1:    3    0    2
' 2:    4    0    3
' The Array contains the following values:
'     0    1    2    3
'     10    11    12    13
'     20    21    22    23
'     100    101    102    103
'     110    111    112    113
'     120    121    122    123 

Комментарии

Класс Array не является частью пространства имен System.Collections.The Array class is not part of the System.Collections namespaces. Тем не менее, он все равно считается коллекцией, так как он основан на интерфейсе IList.However, it is still considered a collection because it is based on the IList interface.

Класс Array является базовым классом для реализаций языков, поддерживающих массивы.The Array class is the base class for language implementations that support arrays. Однако только система и компиляторы могут явно наследовать от класса Array.However, only the system and compilers can derive explicitly from the Array class. Пользователи должны применять конструкции массивов, предоставляемые языком.Users should employ the array constructs provided by the language.

Элемент — это значение в Array.An element is a value in an Array. Длина Array — общее количество элементов, которое может содержать массив.The length of an Array is the total number of elements it can contain. Нижняя граница Array — это индекс его первого элемента.The lower bound of an Array is the index of its first element. Array может иметь любую нижнюю границу, но по умолчанию его нижняя граница равна нулю.An Array can have any lower bound, but it has a lower bound of zero by default. Другая нижняя граница может быть определена при создании экземпляра Array с помощью CreateInstance. Многомерный массив Array может иметь разные границы в каждом измерении.A different lower bound can be defined when creating an instance of the Array class using CreateInstance.A multidimensional Array can have different bounds for each dimension. Массив может иметь не более 32 измерений.An array can have a maximum of 32 dimensions.

В отличие от классов в пространстве имен System.Collections, Array имеет фиксированную емкость.Unlike the classes in the System.Collections namespaces, Array has a fixed capacity. Чтобы увеличить емкость, необходимо создать новый объект Array с требуемой емкостью, скопировать элементы из старого объекта Array в новый, а затем удалить старый Array.To increase the capacity, you must create a new Array object with the required capacity, copy the elements from the old Array object to the new one, and delete the old Array.

Размер массива ограничен максимальным количеством элементов — 4 миллиарда, а также максимальным индексом 0X7FEFFFFF в любом заданном измерении (0X7FFFFFC7 для массивов байтов и однобайтовых структур).The array size is limited to a total of 4 billion elements, and to a maximum index of 0X7FEFFFFF in any given dimension (0X7FFFFFC7 for byte arrays and arrays of single-byte structures).

.NET framework: По умолчанию максимальный размер Array составляет 2 гигабайта (ГБ)..NET Framework only: By default, the maximum size of an Array is 2 gigabytes (GB). В 64-разрядной среде можно избежать ограничения на размер, установив значение атрибута enabled элемента конфигурации gcAllowVeryLargeObjects равным true в среде выполнения.In a 64-bit environment, you can avoid the size restriction by setting the enabled attribute of the gcAllowVeryLargeObjects configuration element to true in the run-time environment.

Одномерные массивы реализуют универсальные интерфейсы System.Collections.Generic.IList<T>, System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyList<T> и System.Collections.Generic.IReadOnlyCollection<T>.Single-dimensional arrays implement the System.Collections.Generic.IList<T>, System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyList<T> and System.Collections.Generic.IReadOnlyCollection<T> generic interfaces. Реализации предоставляются массивам во время выполнения, и таким образом, универсальные интерфейсы не отображаются в синтаксисе объявления класса Array.The implementations are provided to arrays at run time, and as a result, the generic interfaces do not appear in the declaration syntax for the Array class. Кроме того, не существует справочных разделов для членов интерфейса, которые доступны только путем приведения массива к типу универсального интерфейса (явные реализации интерфейса).In addition, there are no reference topics for interface members that are accessible only by casting an array to the generic interface type (explicit interface implementations). Ключевой момент, который необходимо учитывать при приведении массива к одному из этих интерфейсов, заключается в том, что члены, которые добавляют, вставляют или удаляют элементы, вызывают исключение NotSupportedException.The key thing to be aware of when you cast an array to one of these interfaces is that members which add, insert, or remove elements throw NotSupportedException.

Объекты Type предоставляют сведения об объявлениях типов массивов.Type objects provide information about array type declarations. Объекты Array с тем же типом массива имеют одинаковые объекты Type.Array objects with the same array type share the same Type object.

Type.IsArray и Type.GetElementType могут не возвращать ожидаемые результаты с Array, потому что при приведении массива к типу Array результат — это объект, который не является массивом.Type.IsArray and Type.GetElementType might not return the expected results with Array because if an array is cast to the type Array, the result is an object, not an array. То есть typeof(System.Array).IsArray возвращает false, а typeof(System.Array).GetElementType возвращает null.That is, typeof(System.Array).IsArray returns false, and typeof(System.Array).GetElementType returns null.

Метод Array.Copy копирует элементы не только между массивами одного типа, но и между стандартными массивами различных типов; он автоматически осуществляет приведение типов.The Array.Copy method copies elements not only between arrays of the same type but also between standard arrays of different types; it handles type casting automatically.

Некоторые методы, например CreateInstance, Copy, CopyTo, GetValue и SetValue, предоставляют перегрузки, принимающие 64-разрядные целые числа в качестве параметров, для обеспечения возможности работы с массивами большой емкости.Some methods, such as CreateInstance, Copy, CopyTo, GetValue, and SetValue, provide overloads that accept 64-bit integers as parameters to accommodate large capacity arrays. LongLength и GetLongLength возвращают 64-разрядные целые числа, указывающие длину массива.LongLength and GetLongLength return 64-bit integers indicating the length of the array.

Сортировка Array не гарантируется.The Array is not guaranteed to be sorted. Перед выполнением операций, для которых требуется сортировка Array (например, BinarySearch), Array нужно предварительно отсортировать.You must sort the Array prior to performing operations (such as BinarySearch) that require the Array to be sorted.

Использование объектов Array указателей в машинном коде не поддерживается и вызывает исключение NotSupportedException для нескольких методов.Using an Array object of pointers in native code is not supported and will throw a NotSupportedException for several methods.

Свойства

IsFixedSize

Gets a value indicating whether the Array has a fixed size.Gets a value indicating whether the Array has a fixed size.

IsReadOnly

Gets a value indicating whether the Array is read-only.Gets a value indicating whether the Array is read-only.

IsSynchronized

Gets a value indicating whether access to the Array is synchronized (thread safe).Gets a value indicating whether access to the Array is synchronized (thread safe).

Length

Gets the total number of elements in all the dimensions of the Array.Gets the total number of elements in all the dimensions of the Array.

LongLength

Gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array.Gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array.

Rank

Gets the rank (number of dimensions) of the Array.Gets the rank (number of dimensions) of the Array. For example, a one-dimensional array returns 1, a two-dimensional array returns 2, and so on.For example, a one-dimensional array returns 1, a two-dimensional array returns 2, and so on.

SyncRoot

Gets an object that can be used to synchronize access to the Array.Gets an object that can be used to synchronize access to the Array.

Методы

AsReadOnly<T>(T[])

Returns a read-only wrapper for the specified array.Returns a read-only wrapper for the specified array.

BinarySearch(Array, Int32, Int32, Object)

Searches a range of elements in a one-dimensional sorted array for a value, using the IComparable interface implemented by each element of the array and by the specified value.Searches a range of elements in a one-dimensional sorted array for a value, using the IComparable interface implemented by each element of the array and by the specified value.

BinarySearch(Array, Int32, Int32, Object, IComparer)

Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer interface.Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer interface.

BinarySearch(Array, Object)

Searches an entire one-dimensional sorted array for a specific element, using the IComparable interface implemented by each element of the array and by the specified object.Searches an entire one-dimensional sorted array for a specific element, using the IComparable interface implemented by each element of the array and by the specified object.

BinarySearch(Array, Object, IComparer)

Searches an entire one-dimensional sorted array for a value using the specified IComparer interface.Searches an entire one-dimensional sorted array for a value using the specified IComparer interface.

BinarySearch<T>(T[], Int32, Int32, T)

Searches a range of elements in a one-dimensional sorted array for a value, using the IComparable<T> generic interface implemented by each element of the Array and by the specified value.Searches a range of elements in a one-dimensional sorted array for a value, using the IComparable<T> generic interface implemented by each element of the Array and by the specified value.

BinarySearch<T>(T[], Int32, Int32, T, IComparer<T>)

Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer<T> generic interface.Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer<T> generic interface.

BinarySearch<T>(T[], T)

Searches an entire one-dimensional sorted array for a specific element, using the IComparable<T> generic interface implemented by each element of the Array and by the specified object.Searches an entire one-dimensional sorted array for a specific element, using the IComparable<T> generic interface implemented by each element of the Array and by the specified object.

BinarySearch<T>(T[], T, IComparer<T>)

Searches an entire one-dimensional sorted array for a value using the specified IComparer<T> generic interface.Searches an entire one-dimensional sorted array for a value using the specified IComparer<T> generic interface.

Clear(Array, Int32, Int32)

Sets a range of elements in an array to the default value of each element type.Sets a range of elements in an array to the default value of each element type.

Clone()

Creates a shallow copy of the Array.Creates a shallow copy of the Array.

ConstrainedCopy(Array, Int32, Array, Int32, Int32)

Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index.Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. Guarantees that all changes are undone if the copy does not succeed completely.Guarantees that all changes are undone if the copy does not succeed completely.

ConvertAll<TInput,TOutput>(TInput[], Converter<TInput,TOutput>)

Converts an array of one type to an array of another type.Converts an array of one type to an array of another type.

Copy(Array, Array, Int32)

Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element.Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. The length is specified as a 32-bit integer.The length is specified as a 32-bit integer.

Copy(Array, Array, Int64)

Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element.Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. The length is specified as a 64-bit integer.The length is specified as a 64-bit integer.

Copy(Array, Int32, Array, Int32, Int32)

Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index.Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. The length and the indexes are specified as 32-bit integers.The length and the indexes are specified as 32-bit integers.

Copy(Array, Int64, Array, Int64, Int64)

Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index.Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. The length and the indexes are specified as 64-bit integers.The length and the indexes are specified as 64-bit integers.

CopyTo(Array, Int32)

Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index.Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index. The index is specified as a 32-bit integer.The index is specified as a 32-bit integer.

CopyTo(Array, Int64)

Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index.Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index. The index is specified as a 64-bit integer.The index is specified as a 64-bit integer.

CreateInstance(Type, Int32)

Creates a one-dimensional Array of the specified Type and length, with zero-based indexing.Creates a one-dimensional Array of the specified Type and length, with zero-based indexing.

CreateInstance(Type, Int32, Int32)

Creates a two-dimensional Array of the specified Type and dimension lengths, with zero-based indexing.Creates a two-dimensional Array of the specified Type and dimension lengths, with zero-based indexing.

CreateInstance(Type, Int32, Int32, Int32)

Creates a three-dimensional Array of the specified Type and dimension lengths, with zero-based indexing.Creates a three-dimensional Array of the specified Type and dimension lengths, with zero-based indexing.

CreateInstance(Type, Int32[])

Creates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing.Creates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing. The dimension lengths are specified in an array of 32-bit integers.The dimension lengths are specified in an array of 32-bit integers.

CreateInstance(Type, Int32[], Int32[])

Creates a multidimensional Array of the specified Type and dimension lengths, with the specified lower bounds.Creates a multidimensional Array of the specified Type and dimension lengths, with the specified lower bounds.

CreateInstance(Type, Int64[])

Creates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing.Creates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing. The dimension lengths are specified in an array of 64-bit integers.The dimension lengths are specified in an array of 64-bit integers.

Empty<T>()

Returns an empty array.Returns an empty array.

Equals(Object)

Определяет, равен ли указанный объект текущему объекту.Determines whether the specified object is equal to the current object.

(Унаследовано от Object)
Exists<T>(T[], Predicate<T>)

Determines whether the specified array contains elements that match the conditions defined by the specified predicate.Determines whether the specified array contains elements that match the conditions defined by the specified predicate.

Fill<T>(T[], T)

Assigns the given value of type T to each element of the specified array.Assigns the given value of type T to each element of the specified array.

Fill<T>(T[], T, Int32, Int32)

Assigns the given value of type T to the elements of the specified array which are within the range of startIndex (inclusive) and the next count number of indices.Assigns the given value of type T to the elements of the specified array which are within the range of startIndex (inclusive) and the next count number of indices.

Find<T>(T[], Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Array.Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Array.

FindAll<T>(T[], Predicate<T>)

Retrieves all the elements that match the conditions defined by the specified predicate.Retrieves all the elements that match the conditions defined by the specified predicate.

FindIndex<T>(T[], Int32, Int32, Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the Array that starts at the specified index and contains the specified number of elements.Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the Array that starts at the specified index and contains the specified number of elements.

FindIndex<T>(T[], Int32, Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the Array that extends from the specified index to the last element.Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the Array that extends from the specified index to the last element.

FindIndex<T>(T[], Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire Array.Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire Array.

FindLast<T>(T[], Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire Array.Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire Array.

FindLastIndex<T>(T[], Int32, Int32, Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the Array that contains the specified number of elements and ends at the specified index.Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the Array that contains the specified number of elements and ends at the specified index.

FindLastIndex<T>(T[], Int32, Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the Array that extends from the first element to the specified index.Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the Array that extends from the first element to the specified index.

FindLastIndex<T>(T[], Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire Array.Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire Array.

ForEach<T>(T[], Action<T>)

Performs the specified action on each element of the specified array.Performs the specified action on each element of the specified array.

GetEnumerator()

Returns an IEnumerator for the Array.Returns an IEnumerator for the Array.

GetHashCode()

Служит в качестве хэш-функции по умолчанию.Serves as the default hash function.

(Унаследовано от Object)
GetLength(Int32)

Gets a 32-bit integer that represents the number of elements in the specified dimension of the Array.Gets a 32-bit integer that represents the number of elements in the specified dimension of the Array.

GetLongLength(Int32)

Gets a 64-bit integer that represents the number of elements in the specified dimension of the Array.Gets a 64-bit integer that represents the number of elements in the specified dimension of the Array.

GetLowerBound(Int32)

Gets the index of the first element of the specified dimension in the array.Gets the index of the first element of the specified dimension in the array.

GetType()

Возвращает объект Type для текущего экземпляра.Gets the Type of the current instance.

(Унаследовано от Object)
GetUpperBound(Int32)

Gets the index of the last element of the specified dimension in the array.Gets the index of the last element of the specified dimension in the array.

GetValue(Int32)

Gets the value at the specified position in the one-dimensional Array.Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.The index is specified as a 32-bit integer.

GetValue(Int32, Int32)

Gets the value at the specified position in the two-dimensional Array.Gets the value at the specified position in the two-dimensional Array. The indexes are specified as 32-bit integers.The indexes are specified as 32-bit integers.

GetValue(Int32, Int32, Int32)

Gets the value at the specified position in the three-dimensional Array.Gets the value at the specified position in the three-dimensional Array. The indexes are specified as 32-bit integers.The indexes are specified as 32-bit integers.

GetValue(Int32[])

Gets the value at the specified position in the multidimensional Array.Gets the value at the specified position in the multidimensional Array. The indexes are specified as an array of 32-bit integers.The indexes are specified as an array of 32-bit integers.

GetValue(Int64)

Gets the value at the specified position in the one-dimensional Array.Gets the value at the specified position in the one-dimensional Array. The index is specified as a 64-bit integer.The index is specified as a 64-bit integer.

GetValue(Int64, Int64)

Gets the value at the specified position in the two-dimensional Array.Gets the value at the specified position in the two-dimensional Array. The indexes are specified as 64-bit integers.The indexes are specified as 64-bit integers.

GetValue(Int64, Int64, Int64)

Gets the value at the specified position in the three-dimensional Array.Gets the value at the specified position in the three-dimensional Array. The indexes are specified as 64-bit integers.The indexes are specified as 64-bit integers.

GetValue(Int64[])

Gets the value at the specified position in the multidimensional Array.Gets the value at the specified position in the multidimensional Array. The indexes are specified as an array of 64-bit integers.The indexes are specified as an array of 64-bit integers.

IndexOf(Array, Object)

Searches for the specified object and returns the index of its first occurrence in a one-dimensional array.Searches for the specified object and returns the index of its first occurrence in a one-dimensional array.

IndexOf(Array, Object, Int32)

Searches for the specified object in a range of elements of a one-dimensional array, and returns the index of its first occurrence.Searches for the specified object in a range of elements of a one-dimensional array, and returns the index of its first occurrence. The range extends from a specified index to the end of the array.The range extends from a specified index to the end of the array.

IndexOf(Array, Object, Int32, Int32)

Searches for the specified object in a range of elements of a one-dimensional array, and returns the index of ifs first occurrence.Searches for the specified object in a range of elements of a one-dimensional array, and returns the index of ifs first occurrence. The range extends from a specified index for a specified number of elements.The range extends from a specified index for a specified number of elements.

IndexOf<T>(T[], T)

Searches for the specified object and returns the index of its first occurrence in a one-dimensional array.Searches for the specified object and returns the index of its first occurrence in a one-dimensional array.

IndexOf<T>(T[], T, Int32)

Searches for the specified object in a range of elements of a one dimensional array, and returns the index of its first occurrence.Searches for the specified object in a range of elements of a one dimensional array, and returns the index of its first occurrence. The range extends from a specified index to the end of the array.The range extends from a specified index to the end of the array.

IndexOf<T>(T[], T, Int32, Int32)

Searches for the specified object in a range of elements of a one-dimensional array, and returns the index of its first occurrence.Searches for the specified object in a range of elements of a one-dimensional array, and returns the index of its first occurrence. The range extends from a specified index for a specified number of elements.The range extends from a specified index for a specified number of elements.

Initialize()

Initializes every element of the value-type Array by calling the parameterless constructor of the value type.Initializes every element of the value-type Array by calling the parameterless constructor of the value type.

LastIndexOf(Array, Object)

Searches for the specified object and returns the index of the last occurrence within the entire one-dimensional Array.Searches for the specified object and returns the index of the last occurrence within the entire one-dimensional Array.

LastIndexOf(Array, Object, Int32)

Searches for the specified object and returns the index of the last occurrence within the range of elements in the one-dimensional Array that extends from the first element to the specified index.Searches for the specified object and returns the index of the last occurrence within the range of elements in the one-dimensional Array that extends from the first element to the specified index.

LastIndexOf(Array, Object, Int32, Int32)

Searches for the specified object and returns the index of the last occurrence within the range of elements in the one-dimensional Array that contains the specified number of elements and ends at the specified index.Searches for the specified object and returns the index of the last occurrence within the range of elements in the one-dimensional Array that contains the specified number of elements and ends at the specified index.

LastIndexOf<T>(T[], T)

Searches for the specified object and returns the index of the last occurrence within the entire Array.Searches for the specified object and returns the index of the last occurrence within the entire Array.

LastIndexOf<T>(T[], T, Int32)

Searches for the specified object and returns the index of the last occurrence within the range of elements in the Array that extends from the first element to the specified index.Searches for the specified object and returns the index of the last occurrence within the range of elements in the Array that extends from the first element to the specified index.

LastIndexOf<T>(T[], T, Int32, Int32)

Searches for the specified object and returns the index of the last occurrence within the range of elements in the Array that contains the specified number of elements and ends at the specified index.Searches for the specified object and returns the index of the last occurrence within the range of elements in the Array that contains the specified number of elements and ends at the specified index.

MemberwiseClone()

Создает неполную копию текущего объекта Object.Creates a shallow copy of the current Object.

(Унаследовано от Object)
Resize<T>(T[], Int32)

Changes the number of elements of a one-dimensional array to the specified new size.Changes the number of elements of a one-dimensional array to the specified new size.

Reverse(Array)

Reverses the sequence of the elements in the entire one-dimensional Array.Reverses the sequence of the elements in the entire one-dimensional Array.

Reverse(Array, Int32, Int32)

Reverses the sequence of a subset of the elements in the one-dimensional Array.Reverses the sequence of a subset of the elements in the one-dimensional Array.

Reverse<T>(T[])

Reverses the sequence of the elements in the one-dimensional generic array.Reverses the sequence of the elements in the one-dimensional generic array.

Reverse<T>(T[], Int32, Int32)

Reverses the sequence of a subset of the elements in the one-dimensional generic array.Reverses the sequence of a subset of the elements in the one-dimensional generic array.

SetValue(Object, Int32)

Sets a value to the element at the specified position in the one-dimensional Array.Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.The index is specified as a 32-bit integer.

SetValue(Object, Int32, Int32)

Sets a value to the element at the specified position in the two-dimensional Array.Sets a value to the element at the specified position in the two-dimensional Array. The indexes are specified as 32-bit integers.The indexes are specified as 32-bit integers.

SetValue(Object, Int32, Int32, Int32)

Sets a value to the element at the specified position in the three-dimensional Array.Sets a value to the element at the specified position in the three-dimensional Array. The indexes are specified as 32-bit integers.The indexes are specified as 32-bit integers.

SetValue(Object, Int32[])

Sets a value to the element at the specified position in the multidimensional Array.Sets a value to the element at the specified position in the multidimensional Array. The indexes are specified as an array of 32-bit integers.The indexes are specified as an array of 32-bit integers.

SetValue(Object, Int64)

Sets a value to the element at the specified position in the one-dimensional Array.Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 64-bit integer.The index is specified as a 64-bit integer.

SetValue(Object, Int64, Int64)

Sets a value to the element at the specified position in the two-dimensional Array.Sets a value to the element at the specified position in the two-dimensional Array. The indexes are specified as 64-bit integers.The indexes are specified as 64-bit integers.

SetValue(Object, Int64, Int64, Int64)

Sets a value to the element at the specified position in the three-dimensional Array.Sets a value to the element at the specified position in the three-dimensional Array. The indexes are specified as 64-bit integers.The indexes are specified as 64-bit integers.

SetValue(Object, Int64[])

Sets a value to the element at the specified position in the multidimensional Array.Sets a value to the element at the specified position in the multidimensional Array. The indexes are specified as an array of 64-bit integers.The indexes are specified as an array of 64-bit integers.

Sort(Array)

Sorts the elements in an entire one-dimensional Array using the IComparable implementation of each element of the Array.Sorts the elements in an entire one-dimensional Array using the IComparable implementation of each element of the Array.

Sort(Array, Array)

Sorts a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable implementation of each key.Sorts a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable implementation of each key.

Sort(Array, Array, IComparer)

Sorts a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer.Sorts a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer.

Sort(Array, Array, Int32, Int32)

Sorts a range of elements in a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable implementation of each key.Sorts a range of elements in a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable implementation of each key.

Sort(Array, Array, Int32, Int32, IComparer)

Sorts a range of elements in a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer.Sorts a range of elements in a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer.

Sort(Array, IComparer)

Sorts the elements in a one-dimensional Array using the specified IComparer.Sorts the elements in a one-dimensional Array using the specified IComparer.

Sort(Array, Int32, Int32)

Sorts the elements in a range of elements in a one-dimensional Array using the IComparable implementation of each element of the Array.Sorts the elements in a range of elements in a one-dimensional Array using the IComparable implementation of each element of the Array.

Sort(Array, Int32, Int32, IComparer)

Sorts the elements in a range of elements in a one-dimensional Array using the specified IComparer.Sorts the elements in a range of elements in a one-dimensional Array using the specified IComparer.

Sort<T>(T[])

Sorts the elements in an entire Array using the IComparable<T> generic interface implementation of each element of the Array.Sorts the elements in an entire Array using the IComparable<T> generic interface implementation of each element of the Array.

Sort<T>(T[], Comparison<T>)

Sorts the elements in an Array using the specified Comparison<T>.Sorts the elements in an Array using the specified Comparison<T>.

Sort<T>(T[], IComparer<T>)

Sorts the elements in an Array using the specified IComparer<T> generic interface.Sorts the elements in an Array using the specified IComparer<T> generic interface.

Sort<T>(T[], Int32, Int32)

Sorts the elements in a range of elements in an Array using the IComparable<T> generic interface implementation of each element of the Array.Sorts the elements in a range of elements in an Array using the IComparable<T> generic interface implementation of each element of the Array.

Sort<T>(T[], Int32, Int32, IComparer<T>)

Sorts the elements in a range of elements in an Array using the specified IComparer<T> generic interface.Sorts the elements in a range of elements in an Array using the specified IComparer<T> generic interface.

Sort<TKey,TValue>(TKey[], TValue[])

Sorts a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable<T> generic interface implementation of each key.Sorts a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable<T> generic interface implementation of each key.

Sort<TKey,TValue>(TKey[], TValue[], IComparer<TKey>)

Sorts a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer<T> generic interface.Sorts a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer<T> generic interface.

Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32)

Sorts a range of elements in a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable<T> generic interface implementation of each key.Sorts a range of elements in a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable<T> generic interface implementation of each key.

Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32, IComparer<TKey>)

Sorts a range of elements in a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer<T> generic interface.Sorts a range of elements in a pair of Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer<T> generic interface.

ToString()

Возвращает строку, представляющую текущий объект.Returns a string that represents the current object.

(Унаследовано от Object)
TrueForAll<T>(T[], Predicate<T>)

Determines whether every element in the array matches the conditions defined by the specified predicate.Determines whether every element in the array matches the conditions defined by the specified predicate.

Явные реализации интерфейса

ICollection.Count

Gets the number of elements contained in the Array.Gets the number of elements contained in the Array.

ICollection.IsSynchronized

Gets a value that indicates whether access to the Array is synchronized (thread safe).Gets a value that indicates whether access to the Array is synchronized (thread safe).

ICollection.SyncRoot

Gets an object that can be used to synchronize access to the Array.Gets an object that can be used to synchronize access to the Array.

IList.Add(Object)

Calling this method always throws a NotSupportedException exception.Calling this method always throws a NotSupportedException exception.

IList.Clear()

Removes all items from the IList.Removes all items from the IList.

IList.Contains(Object)

Determines whether an element is in the IList.Determines whether an element is in the IList.

IList.IndexOf(Object)

Determines the index of a specific item in the IList.Determines the index of a specific item in the IList.

IList.Insert(Int32, Object)

Inserts an item to the IList at the specified index.Inserts an item to the IList at the specified index.

IList.IsFixedSize

Gets a value that indicates whether the Array has a fixed size.Gets a value that indicates whether the Array has a fixed size.

IList.IsReadOnly

Gets a value that indicates whether the Array is read-only.Gets a value that indicates whether the Array is read-only.

IList.Item[Int32]

Gets or sets the element at the specified index.Gets or sets the element at the specified index.

IList.Remove(Object)

Removes the first occurrence of a specific object from the IList.Removes the first occurrence of a specific object from the IList.

IList.RemoveAt(Int32)

Removes the IList item at the specified index.Removes the IList item at the specified index.

IStructuralComparable.CompareTo(Object, IComparer)

Determines whether the current collection object precedes, occurs in the same position as, or follows another object in the sort order.Determines whether the current collection object precedes, occurs in the same position as, or follows another object in the sort order.

IStructuralEquatable.Equals(Object, IEqualityComparer)

Determines whether an object is equal to the current instance.Determines whether an object is equal to the current instance.

IStructuralEquatable.GetHashCode(IEqualityComparer)

Returns a hash code for the current instance.Returns a hash code for the current instance.

Методы расширения

Cast<TResult>(IEnumerable)

Приводит элементы объекта IEnumerable к заданному типу.Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Выполняет фильтрацию элементов объекта IEnumerable по заданному типу.Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.Converts an IEnumerable to an IQueryable.

Применяется к

Потокобезопасность

Открытые статические (Shared в Visual Basic) члены этого типа являются потокобезопасными.Public static (Shared in Visual Basic) members of this type are thread safe. Потокобезопасность элементов экземпляров не гарантируется.Any instance members are not guaranteed to be thread safe.

Эта реализация не предоставляет синхронизированную (потокобезопасную) оболочку для Array, однако классы .NET Framework, основанные на Array, предоставляют собственную синхронизированную версию коллекции с помощью свойства SyncRoot.This implementation does not provide a synchronized (thread safe) wrapper for an Array; however, .NET Framework classes based on Array provide their own synchronized version of the collection using the SyncRoot property.

Перечисление коллекции не является потокобезопасной процедурой.Enumerating through a collection is intrinsically not a thread-safe procedure. Даже если коллекция синхронизирована, другие потоки могут ее изменить, что приведет к тому, что перечислитель создаст исключение.Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. Для обеспечения потокобезопасности при перечислении можно либо заблокировать коллекцию на все время перечисления, либо перехватывать исключения, возникающие в результате изменений, внесенных другими потоками.To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

Дополнительно