Array Array Array Array Class

定义

提供一些方法,用于创建、处理、搜索数组并对数组进行排序,从而充当公共语言运行时中所有数组的基类。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 : ICloneable, System::Collections::IList, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
[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 ICloneable
    interface ICollection
    interface IList
    interface IEnumerable
    interface IStructuralComparable
    interface IStructuralEquatable
Public MustInherit Class Array
Implements ICloneable, IList, IStructuralComparable, IStructuralEquatable
继承
ArrayArrayArrayArray
属性
实现

示例

下面的代码示例演示 Array.Copy 如何复制类型为 integer 的数组和 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
 */
using System;

public class SamplesArray2
{
    public static void Main()
    {
        // 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);
    }


    public static 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 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 

注解

@No__t-0 类不是 @no__t 命名空间的一部分。The Array class is not part of the System.Collections namespaces. 但是,它仍被视为集合,因为它基于 @no__t 0 接口。However, it is still considered a collection because it is based on the IList interface.

@No__t-0 类是支持数组的语言实现的基类。The Array class is the base class for language implementations that support arrays. 但是,仅系统和编译器可以从 @no__t 的类中显式派生。However, only the system and compilers can derive explicitly from the Array class. 用户应使用该语言提供的数组构造。Users should employ the array constructs provided by the language.

元素是 @no__t 0 中的值。An element is a value in an Array. @No__t 的长度为它可以包含的元素总数。The length of an Array is the total number of elements it can contain. @No__t 的下限是其第一个元素的索引。The lower bound of an Array is the index of its first element. @No__t 0 可以有任何下限,但默认情况下它的下限为零。An Array can have any lower bound, but it has a lower bound of zero by default. 使用 @no__t 创建 Array 类的实例时,可以定义其他下限。多维 @no__t 的每个维度可以有不同的界限。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. 若要增加容量,必须创建具有所需容量的新 @no__t 0 对象,将旧 @no__t 对象中的元素复制到新对象,并删除旧的 ArrayTo 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.

数组大小限制为总计4000000000个元素,在任何给定维度中限制为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: 默认情况下,@no__t 的最大大小为2千兆字节(GB)。.NET Framework only: By default, the maximum size of an Array is 2 gigabytes (GB). 在64位环境中,可以通过将gcAllowVeryLargeObjects配置元素的 enabled 特性设置为运行时环境中 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>、@no__t @no__t 和 @no__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). 将数组强制转换为这些接口之一时要注意的关键一点是,添加、插入或删除元素的成员引发 NotSupportedExceptionThe 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. 具有相同数组类型 @no__t 0 对象共享同一 @no__t 1 对象。Array objects with the same array type share the same Type object.

Type.IsArrayType.GetElementType 可能不会返回 @no__t 为-2 的预期结果,因为如果将数组强制转换为类型 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. 也就是说,@no__t 返回 falsetypeof(System.Array).GetElementType 返回 nullThat is, typeof(System.Array).IsArray returns false, and typeof(System.Array).GetElementType returns null.

@No__t-0 方法不仅复制相同类型的数组中的元素,还复制不同类型的标准数组之间的元素;它自动处理类型强制转换。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.

某些方法(例如 CreateInstanceCopyCopyToGetValue 和 @no__t)提供接受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. LongLengthGetLongLength 返回64位整数,指示数组的长度。LongLength and GetLongLength return 64-bit integers indicating the length of the array.

不保证对 Array 进行排序。The Array is not guaranteed to be sorted. 必须先对 Array 进行排序,然后才能执行需要对 @no__t 进行排序的操作(如 BinarySearch)。You must sort the Array prior to performing operations (such as BinarySearch) that require the Array to be sorted.

在本机代码中不支持使用指针的 @no__t 0 对象,并将为多个方法引发 NotSupportedExceptionUsing an Array object of pointers in native code is not supported and will throw a NotSupportedException for several methods.

属性

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

获取一个值,该值指示 Array 是否具有固定大小。Gets a value indicating whether the Array has a fixed size.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取一个值,该值指示 Array 是否为只读。Gets a value indicating whether the Array is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

获取一个值,该值指示是否同步对 Array 的访问(线程安全)。Gets a value indicating whether access to the Array is synchronized (thread safe).

Length Length Length Length

获取 Array 的所有维度中的元素总数。Gets the total number of elements in all the dimensions of the Array.

LongLength LongLength LongLength LongLength

获取一个 64 位整数,该整数表示 Array 的所有维数中元素的总数。Gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array.

Rank Rank Rank Rank

获取 Array 的秩(维数)。Gets the rank (number of dimensions) of the Array. 例如,一维数组返回 1,二维数组返回 2,依次类推。For example, a one-dimensional array returns 1, a two-dimensional array returns 2, and so on.

SyncRoot SyncRoot SyncRoot SyncRoot

获取可用于同步对 Array 的访问的对象。Gets an object that can be used to synchronize access to the Array.

方法

AsReadOnly<T>(T[]) AsReadOnly<T>(T[]) AsReadOnly<T>(T[]) AsReadOnly<T>(T[])

返回指定数组的只读包装。Returns a read-only wrapper for the specified array.

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

使用由一维排序数组中每个元素和指定的值实现的 IComparable 接口,在该数组的一个元素范围内搜索值。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) BinarySearch(Array, Int32, Int32, Object, IComparer) BinarySearch(Array, Int32, Int32, Object, IComparer) BinarySearch(Array, Int32, Int32, Object, IComparer)

使用指定 IComparer 接口,在一维排序数组的某个元素范围中搜索值。Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer interface.

BinarySearch(Array, Object) BinarySearch(Array, Object) BinarySearch(Array, Object) BinarySearch(Array, Object)

使用由数组中每个元素和指定对象实现的 IComparable 接口,在整个一维排序数组中搜索特定元素。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) BinarySearch(Array, Object, IComparer) BinarySearch(Array, Object, IComparer) BinarySearch(Array, Object, IComparer)

使用指定 IComparer 接口,在整个一维排序数组中搜索值。Searches an entire one-dimensional sorted array for a value using the specified IComparer interface.

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

使用由 Array 中每个元素和指定值实现的 IComparable<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.

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

使用指定 IComparer<T> 泛型接口,在一维排序数组的某个元素范围中搜索值。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) BinarySearch<T>(T[], T) BinarySearch<T>(T[], T) BinarySearch<T>(T[], T)

使用由 Array 中每个元素和指定对象实现的 IComparable<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.

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

使用指定 IComparer<T> 泛型接口,在整个一维排序数组中搜索值。Searches an entire one-dimensional sorted array for a value using the specified IComparer<T> generic interface.

Clear(Array, Int32, Int32) Clear(Array, Int32, Int32) Clear(Array, Int32, Int32) Clear(Array, Int32, Int32)

将数组中的某个范围的元素设置为每个元素类型的默认值。Sets a range of elements in an array to the default value of each element type.

Clone() Clone() Clone() Clone()

创建 Array 的浅表副本。Creates a shallow copy of the Array.

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

复制 Array 中的一系列元素(从指定的源索引开始),并将它们粘贴到另一 Array 中(从指定的目标索引开始)。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.

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

将一种类型的数组转换为另一种类型的数组。Converts an array of one type to an array of another type.

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

从第一个元素开始复制 Array 中的一系列元素,将它们粘贴到另一 Array 中(从第一个元素开始)。Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. 长度指定为 32 位整数。The length is specified as a 32-bit integer.

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

从第一个元素开始复制 Array 中的一系列元素,将它们粘贴到另一 Array 中(从第一个元素开始)。Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. 长度指定为 64 位整数。The length is specified as a 64-bit integer.

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

复制 Array 中的一系列元素(从指定的源索引开始),并将它们粘贴到另一 Array 中(从指定的目标索引开始)。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. 长度和索引指定为 32 位整数。The length and the indexes are specified as 32-bit integers.

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

复制 Array 中的一系列元素(从指定的源索引开始),并将它们粘贴到另一 Array 中(从指定的目标索引开始)。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. 长度和索引指定为 64 位整数。The length and the indexes are specified as 64-bit integers.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) 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. 索引指定为 32 位整数。The index is specified as a 32-bit integer.

CopyTo(Array, Int64) CopyTo(Array, Int64) CopyTo(Array, Int64) 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. 索引指定为 64 位整数。The index is specified as a 64-bit integer.

CreateInstance(Type, Int32) CreateInstance(Type, Int32) CreateInstance(Type, Int32) CreateInstance(Type, Int32)

创建使用从零开始的索引、具有指定 Type 和长度的一维 ArrayCreates a one-dimensional Array of the specified Type and length, with zero-based indexing.

CreateInstance(Type, Int32, Int32) CreateInstance(Type, Int32, Int32) CreateInstance(Type, Int32, Int32) CreateInstance(Type, Int32, Int32)

创建使用从零开始的索引、具有指定 Array 和维长的二维 TypeCreates a two-dimensional Array of the specified Type and dimension lengths, with zero-based indexing.

CreateInstance(Type, Int32, Int32, Int32) CreateInstance(Type, Int32, Int32, Int32) CreateInstance(Type, Int32, Int32, Int32) CreateInstance(Type, Int32, Int32, Int32)

创建使用从零开始的索引、具有指定 Type 和维长的三维 ArrayCreates a three-dimensional Array of the specified Type and dimension lengths, with zero-based indexing.

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

创建索引从零开始、具有指定 Type 和维长的多维 ArrayCreates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing. 维的长度在一个 32 位整数数组中指定。The dimension lengths are specified in an array of 32-bit integers.

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

创建具有指定下限、指定 Array 和维长的多维 TypeCreates a multidimensional Array of the specified Type and dimension lengths, with the specified lower bounds.

CreateInstance(Type, Int64[]) CreateInstance(Type, Int64[]) CreateInstance(Type, Int64[]) CreateInstance(Type, Int64[])

创建索引从零开始、具有指定 Type 和维长的多维 ArrayCreates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing. 维度的长度在一个 64 位整数数组中指定。The dimension lengths are specified in an array of 64-bit integers.

Empty<T>() Empty<T>() Empty<T>() Empty<T>()

返回一个空数组。Returns an empty array.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Exists<T>(T[], Predicate<T>) Exists<T>(T[], Predicate<T>) Exists<T>(T[], Predicate<T>) Exists<T>(T[], Predicate<T>)

确定指定数组包含的元素是否与指定谓词定义的条件匹配。Determines whether the specified array contains elements that match the conditions defined by the specified predicate.

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

将类型为 T 的给定 value 分配给指定的 array 的每个元素。Assigns the given value of type T to each element of the specified array.

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

将类型为 T 的给定 value 分配给指定的 array 的元素,其位于索引的 startIndex(含)到后续 count 数的范围内。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>) Find<T>(T[], Predicate<T>) Find<T>(T[], Predicate<T>) Find<T>(T[], Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回整个 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>) FindAll<T>(T[], Predicate<T>) FindAll<T>(T[], Predicate<T>) FindAll<T>(T[], Predicate<T>)

检索与指定谓词定义的条件匹配的所有元素。Retrieves all the elements that match the conditions defined by the specified predicate.

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

搜索与指定谓词所定义的条件相匹配的一个元素,并返回 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 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>) FindIndex<T>(T[], Int32, Predicate<T>) FindIndex<T>(T[], Int32, Predicate<T>) FindIndex<T>(T[], Int32, Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回 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 range of elements in the Array that extends from the specified index to the last element.

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

搜索与指定谓词所定义的条件相匹配的元素,并返回整个 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>) FindLast<T>(T[], Predicate<T>) FindLast<T>(T[], Predicate<T>) FindLast<T>(T[], Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回整个 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>) FindLastIndex<T>(T[], Int32, Int32, Predicate<T>) FindLastIndex<T>(T[], Int32, Int32, Predicate<T>) FindLastIndex<T>(T[], Int32, Int32, Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回 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 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>) FindLastIndex<T>(T[], Int32, Predicate<T>) FindLastIndex<T>(T[], Int32, Predicate<T>) FindLastIndex<T>(T[], Int32, Predicate<T>)

搜索与由指定谓词定义的条件相匹配的元素,并返回 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 range of elements in the Array that extends from the first element to the specified index.

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

搜索与指定谓词所定义的条件相匹配的元素,并返回整个 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>) ForEach<T>(T[], Action<T>) ForEach<T>(T[], Action<T>) ForEach<T>(T[], Action<T>)

对指定数组的每个元素执行指定操作。Performs the specified action on each element of the specified array.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回 IEnumeratorArrayReturns an IEnumerator for the Array.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetLength(Int32) GetLength(Int32) GetLength(Int32) GetLength(Int32)

获取一个 32 位整数,该整数表示 Array 的指定维中的元素数。Gets a 32-bit integer that represents the number of elements in the specified dimension of the Array.

GetLongLength(Int32) GetLongLength(Int32) GetLongLength(Int32) GetLongLength(Int32)

获取一个 64 位整数,该整数表示 Array 的指定维中的元素数。Gets a 64-bit integer that represents the number of elements in the specified dimension of the Array.

GetLowerBound(Int32) GetLowerBound(Int32) GetLowerBound(Int32) GetLowerBound(Int32)

获取数组中指定维度第一个元素的索引。Gets the index of the first element of the specified dimension in the array.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetUpperBound(Int32) GetUpperBound(Int32) GetUpperBound(Int32) GetUpperBound(Int32)

获取数组中指定维度最后一个元素的索引。Gets the index of the last element of the specified dimension in the array.

GetValue(Int32) GetValue(Int32) GetValue(Int32) GetValue(Int32)

获取一维 Array 中指定位置的值。Gets the value at the specified position in the one-dimensional Array. 索引指定为 32 位整数。The index is specified as a 32-bit integer.

GetValue(Int32, Int32) GetValue(Int32, Int32) GetValue(Int32, Int32) GetValue(Int32, Int32)

获取二维 Array 中指定位置的值。Gets the value at the specified position in the two-dimensional Array. 索引指定为 32 位整数。The indexes are specified as 32-bit integers.

GetValue(Int32, Int32, Int32) GetValue(Int32, Int32, Int32) GetValue(Int32, Int32, Int32) GetValue(Int32, Int32, Int32)

获取三维 Array 中指定位置的值。Gets the value at the specified position in the three-dimensional Array. 索引指定为 32 位整数。The indexes are specified as 32-bit integers.

GetValue(Int32[]) GetValue(Int32[]) GetValue(Int32[]) GetValue(Int32[])

获取多维 Array 中指定位置的值。Gets the value at the specified position in the multidimensional Array. 索引指定为一个 32 位整数数组。The indexes are specified as an array of 32-bit integers.

GetValue(Int64) GetValue(Int64) GetValue(Int64) GetValue(Int64)

获取一维 Array 中指定位置的值。Gets the value at the specified position in the one-dimensional Array. 索引指定为 64 位整数。The index is specified as a 64-bit integer.

GetValue(Int64, Int64) GetValue(Int64, Int64) GetValue(Int64, Int64) GetValue(Int64, Int64)

获取二维 Array 中指定位置的值。Gets the value at the specified position in the two-dimensional Array. 索引指定为 64 位整数。The indexes are specified as 64-bit integers.

GetValue(Int64, Int64, Int64) GetValue(Int64, Int64, Int64) GetValue(Int64, Int64, Int64) GetValue(Int64, Int64, Int64)

获取三维 Array 中指定位置的值。Gets the value at the specified position in the three-dimensional Array. 索引指定为 64 位整数。The indexes are specified as 64-bit integers.

GetValue(Int64[]) GetValue(Int64[]) GetValue(Int64[]) GetValue(Int64[])

获取多维 Array 中指定位置的值。Gets the value at the specified position in the multidimensional Array. 索引指定为一个 64 位整数数组。The indexes are specified as an array of 64-bit integers.

IndexOf(Array, Object) IndexOf(Array, Object) IndexOf(Array, Object) IndexOf(Array, Object)

在一个一维数组中搜索指定对象,并返回其首个匹配项的索引。Searches for the specified object and returns the index of its first occurrence in a one-dimensional array.

IndexOf(Array, Object, Int32) IndexOf(Array, Object, Int32) IndexOf(Array, Object, Int32) 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. 范围从指定索引到该数组结尾。The range extends from a specified index to the end of the array.

IndexOf(Array, Object, Int32, Int32) IndexOf(Array, Object, Int32, Int32) IndexOf(Array, Object, Int32, Int32) 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. 该元素系列的范围从指定数量的元素的指定索引开始。The range extends from a specified index for a specified number of elements.

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

在一个一维数组中搜索指定对象,并返回其首个匹配项的索引。Searches for the specified object and returns the index of its first occurrence in a one-dimensional array.

IndexOf<T>(T[], T, Int32) IndexOf<T>(T[], T, Int32) IndexOf<T>(T[], T, Int32) 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. 范围从指定索引到该数组结尾。The range extends from a specified index to the end of the array.

IndexOf<T>(T[], T, Int32, Int32) IndexOf<T>(T[], T, Int32, Int32) IndexOf<T>(T[], T, Int32, Int32) 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. 该元素系列的范围从指定数量的元素的指定索引开始。The range extends from a specified index for a specified number of elements.

Initialize() Initialize() Initialize() Initialize()

通过调用值类型的无参数构造函数,初始化值类型 Array 的每一个元素。Initializes every element of the value-type Array by calling the parameterless constructor of the value type.

LastIndexOf(Array, Object) LastIndexOf(Array, Object) LastIndexOf(Array, Object) LastIndexOf(Array, Object)

搜索指定的对象,并返回整个一维 Array 中最后一个匹配项的索引。Searches for the specified object and returns the index of the last occurrence within the entire one-dimensional Array.

LastIndexOf(Array, Object, Int32) LastIndexOf(Array, Object, Int32) LastIndexOf(Array, Object, Int32) LastIndexOf(Array, Object, Int32)

搜索指定的对象,并返回一维 Array 中从第一个元素到指定索引这部分元素中最后一个匹配项的索引。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) LastIndexOf(Array, Object, Int32, Int32) LastIndexOf(Array, Object, Int32, Int32) LastIndexOf(Array, Object, Int32, Int32)

搜索指定的对象,并返回一维 Array 中到指定索引为止包含指定个元素的这部分元素中最后一个匹配项的索引。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) LastIndexOf<T>(T[], T) LastIndexOf<T>(T[], T) LastIndexOf<T>(T[], T)

搜索指定的对象,并返回整个 Array 中最后一个匹配项的索引。Searches for the specified object and returns the index of the last occurrence within the entire Array.

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

搜索指定的对象,并返回 Array 中从第一个元素到指定索引这部分元素中最后一个匹配项的索引。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) LastIndexOf<T>(T[], T, Int32, Int32) LastIndexOf<T>(T[], T, Int32, Int32) LastIndexOf<T>(T[], T, Int32, Int32)

搜索指定的对象,并返回 Array 中到指定索引为止包含指定个元素的这部分元素中最后一个匹配项的索引。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() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Resize<T>(T[], Int32) Resize<T>(T[], Int32) Resize<T>(T[], Int32) Resize<T>(T[], Int32)

将一维数组的元素数更改为指定的新大小。Changes the number of elements of a one-dimensional array to the specified new size.

Reverse(Array) Reverse(Array) Reverse(Array) Reverse(Array)

反转整个一维 Array 中元素的顺序。Reverses the sequence of the elements in the entire one-dimensional Array.

Reverse(Array, Int32, Int32) Reverse(Array, Int32, Int32) Reverse(Array, Int32, Int32) Reverse(Array, Int32, Int32)

反转一维 Array 中某部分元素的元素顺序。Reverses the sequence of the elements in a range of elements in the one-dimensional Array.

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

将某值设置给一维 Array 中指定位置的元素。Sets a value to the element at the specified position in the one-dimensional Array. 索引指定为 32 位整数。The index is specified as a 32-bit integer.

SetValue(Object, Int32, Int32) SetValue(Object, Int32, Int32) SetValue(Object, Int32, Int32) SetValue(Object, Int32, Int32)

将某值设置给二维 Array 中指定位置的元素。Sets a value to the element at the specified position in the two-dimensional Array. 索引指定为 32 位整数。The indexes are specified as 32-bit integers.

SetValue(Object, Int32, Int32, Int32) SetValue(Object, Int32, Int32, Int32) SetValue(Object, Int32, Int32, Int32) SetValue(Object, Int32, Int32, Int32)

将值设置为三维 Array 中指定位置的元素。Sets a value to the element at the specified position in the three-dimensional Array. 索引指定为 32 位整数。The indexes are specified as 32-bit integers.

SetValue(Object, Int32[]) SetValue(Object, Int32[]) SetValue(Object, Int32[]) SetValue(Object, Int32[])

将某值设置给多维 Array 中指定位置的元素。Sets a value to the element at the specified position in the multidimensional Array. 索引指定为一个 32 位整数数组。The indexes are specified as an array of 32-bit integers.

SetValue(Object, Int64) SetValue(Object, Int64) SetValue(Object, Int64) SetValue(Object, Int64)

将值设置为一维 Array 中指定位置的元素。Sets a value to the element at the specified position in the one-dimensional Array. 索引指定为 64 位整数。The index is specified as a 64-bit integer.

SetValue(Object, Int64, Int64) SetValue(Object, Int64, Int64) SetValue(Object, Int64, Int64) SetValue(Object, Int64, Int64)

将某值设置给二维 Array 中指定位置的元素。Sets a value to the element at the specified position in the two-dimensional Array. 索引指定为 64 位整数。The indexes are specified as 64-bit integers.

SetValue(Object, Int64, Int64, Int64) SetValue(Object, Int64, Int64, Int64) SetValue(Object, Int64, Int64, Int64) SetValue(Object, Int64, Int64, Int64)

将某值设置给三维 Array 中指定位置的元素。Sets a value to the element at the specified position in the three-dimensional Array. 索引指定为 64 位整数。The indexes are specified as 64-bit integers.

SetValue(Object, Int64[]) SetValue(Object, Int64[]) SetValue(Object, Int64[]) SetValue(Object, Int64[])

将值设置为多维 Array 中指定位置的元素。Sets a value to the element at the specified position in the multidimensional Array. 索引指定为一个 64 位整数数组。The indexes are specified as an array of 64-bit integers.

Sort(Array) Sort(Array) Sort(Array) Sort(Array)

使用 Array 中每个元素的 IComparable 实现,对整个一维 Array 中的元素进行排序。Sorts the elements in an entire one-dimensional Array using the IComparable implementation of each element of the Array.

Sort(Array, Array) Sort(Array, Array) Sort(Array, Array) Sort(Array, Array)

基于第一个 Array 中的关键字,使用每个关键字的 IComparable 实现,对两个一维 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.

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

基于第一个 Array 中的关键字,使用指定的 IComparer,对两个一维 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 specified IComparer.

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

基于第一个 Array 中的关键字,使用每个关键字的 IComparable 实现,对两个一维 Array 对象(一个包含关键字,另一个包含对应的项)的部分元素进行排序。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) Sort(Array, Array, Int32, Int32, IComparer) Sort(Array, Array, Int32, Int32, IComparer) Sort(Array, Array, Int32, Int32, IComparer)

基于第一个 Array 中的关键字,使用指定的 IComparer,对两个一维 Array 对象(一个包含关键字,另一个包含对应的项)的部分元素进行排序。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) Sort(Array, IComparer) Sort(Array, IComparer) Sort(Array, IComparer)

使用指定的 IComparer,对一维 Array 中的元素进行排序。Sorts the elements in a one-dimensional Array using the specified IComparer.

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

使用 Array 中每个元素的 IComparable 实现,对一维 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) Sort(Array, Int32, Int32, IComparer) Sort(Array, Int32, Int32, IComparer) Sort(Array, Int32, Int32, IComparer)

使用指定的 IComparer,对一维 Array 中的部分元素进行排序。Sorts the elements in a range of elements in a one-dimensional Array using the specified IComparer.

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

使用 Array 中每个元素的 IComparable<T> 泛型接口实现,对整个 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>) Sort<T>(T[], Comparison<T>) Sort<T>(T[], Comparison<T>) Sort<T>(T[], Comparison<T>)

使用指定的 Comparison<T>,对 Array 中的元素进行排序。Sorts the elements in an Array using the specified Comparison<T>.

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

使用指定的 IComparer<T> 泛型接口,对 Array 中的元素进行排序。Sorts the elements in an Array using the specified IComparer<T> generic interface.

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

使用 Array 中每个元素的 IComparable<T> 泛型接口实现,对 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>) Sort<T>(T[], Int32, Int32, IComparer<T>) Sort<T>(T[], Int32, Int32, IComparer<T>) Sort<T>(T[], Int32, Int32, IComparer<T>)

使用指定的 IComparer<T> 泛型接口,对 Array 中的部分元素进行排序。Sorts the elements in a range of elements in an Array using the specified IComparer<T> generic interface.

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

基于第一个 Array 中的键,使用每个键的 IComparable<T> 泛型接口实现,对一对 Array 对象(一个包含键,另一个包含对应的项)进行排序。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>) Sort<TKey,TValue>(TKey[], TValue[], IComparer<TKey>) Sort<TKey,TValue>(TKey[], TValue[], IComparer<TKey>) Sort<TKey,TValue>(TKey[], TValue[], IComparer<TKey>)

基于第一个 Array 中的关键字,使用指定的 IComparer<T> 泛型接口,对两个 Array 对象(一个包含关键字,另一个包含对应的项)进行排序。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) Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32) Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32) Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32)

基于第一个 Array 中的键,使用每个键的 IComparable<T> 泛型接口实现,对两个 Array 对象(一个包含键,另一个包含对应的项)的部分元素进行排序。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>) Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32, IComparer<TKey>) Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32, IComparer<TKey>) Sort<TKey,TValue>(TKey[], TValue[], Int32, Int32, IComparer<TKey>)

基于第一个 Array 中的关键字,使用指定的 IComparer<T> 泛型接口,对两个 Array 对象(一个包含关键字,另一个包含对应的项)的部分元素进行排序。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() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
TrueForAll<T>(T[], Predicate<T>) TrueForAll<T>(T[], Predicate<T>) TrueForAll<T>(T[], Predicate<T>) TrueForAll<T>(T[], Predicate<T>)

确定数组中的每个元素是否都与指定谓词定义的条件匹配。Determines whether every element in the array matches the conditions defined by the specified predicate.

显式界面实现

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

获取 Array 中包含的元素数。Gets the number of elements contained in the Array.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

获取一个值,该值指示对 Array 的访问是否同步(线程安全)。Gets a value that indicates whether access to the Array is synchronized (thread safe).

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

获取可用于同步对 Array 的访问的对象。Gets an object that can be used to synchronize access to the Array.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

调用此方法始终会引发 NotSupportedException 异常。Calling this method always throws a NotSupportedException exception.

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

IList 中移除所有项。Removes all items from the IList.

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

确定某元素是否在 IList 中。Determines whether an element is in the IList.

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

确定 IList 中特定项的索引。Determines the index of a specific item in the IList.

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

IList 中的指定索引处插入一个项。Inserts an item to the IList at the specified index.

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

获取一个值,该值指示 Array 是否具有固定大小。Gets a value that indicates whether the Array has a fixed size.

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

获取一个值,该值指示 Array 是否为只读。Gets a value that indicates whether the Array is read-only.

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

获取或设置指定索引处的元素。Gets or sets the element at the specified index.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

IList 中移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the IList.

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

移除位于指定索引处的 IList 项。Removes the IList item at the specified index.

IStructuralComparable.CompareTo(Object, IComparer) IStructuralComparable.CompareTo(Object, IComparer) IStructuralComparable.CompareTo(Object, IComparer) 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.

IStructuralEquatable.Equals(Object, IEqualityComparer) IStructuralEquatable.Equals(Object, IEqualityComparer) IStructuralEquatable.Equals(Object, IEqualityComparer) IStructuralEquatable.Equals(Object, IEqualityComparer)

确定某个对象与当前实例是否相等。Determines whether an object is equal to the current instance.

IStructuralEquatable.GetHashCode(IEqualityComparer) IStructuralEquatable.GetHashCode(IEqualityComparer) IStructuralEquatable.GetHashCode(IEqualityComparer) IStructuralEquatable.GetHashCode(IEqualityComparer)

返回当前实例的哈希代码。Returns a hash code for the current instance.

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

线程安全性

此类型的公共静态(@no__t 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.

此实现不提供 @no__t 的同步(线程安全)包装器;但是,基于 @no__t 的 .NET Framework 类将使用 @no__t 2 属性提供其自己的同步版本的集合。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.

另请参阅