Array Array Array Array Class

定義

提供建立、管理、搜尋和排序陣列的方法,可在 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 : 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 

備註

類別不是System.Collections命名空間的一部分。 ArrayThe 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.

陣列大小限制為總計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: 根據預設,的大小Array上限為 2 gb。.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.IsArrayType.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).GetElementTypenull傳回。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.

某些方法(例如CreateInstanceCopyCopyToGetValueSetValue)提供可接受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 ,才能執行需要Array排序的作業BinarySearch(例如)。You must sort the Array prior to performing operations (such as BinarySearch) that require the Array to be sorted.

不支援在機器碼中使用指標的NotSupportedException 物件,而且會針對數個方法擲回。ArrayUsing 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

取得代表 Array 所有維度的元素總數之 64 位元整數。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)

建立指定 Array 和長度的一維 Type (具有以零起始的索引)。Creates 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)

建立指定 Type 和維度長度的二維 Array (具有以零為起始的索引)。Creates 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 和維度長度的三維 Array (具有以零為起始的索引)。Creates 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[])

建立指定 Array 和維度長度的多維 Type (具有以零起始的索引)。Creates 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[])

建立指定 Type 和維度長度的多維 Array (具有指定的下限)。Creates 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[])

建立指定 Array 和維度長度的多維 Type (具有以零起始的索引)。Creates 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>)

判斷指定的陣列是否包含符合指定之述詞 (Predicate) 所定義的條件之元素。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)
Fill<T>(T[], T, Int32, Int32) Fill<T>(T[], T, Int32, Int32) Fill<T>(T[], T, Int32, Int32) Fill<T>(T[], T, Int32, Int32)
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)

取得代表 Array 指定維度之元素數目的 32 位元整數。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)

取得代表 Array 指定維度之元素數目的 64 位元整數。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 的淺層複本 (Shallow Copy)。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 實作,根據第一個 Array 中的索引鍵,排序一對一維的 IComparable 物件 (一個物件包含索引鍵,另一個物件包含對應的項目)。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,根據第一個 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.

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

使用每個索引鍵的 Array 實作,根據第一個 Array 中的索引鍵,排序一對一維的 IComparable 物件中某個範圍的元素 (一個物件包含索引鍵,另一個物件包含對應的項目)。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,根據第一個 Array 中的索引鍵,排序一對一維的 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) Sort(Array, IComparer) Sort(Array, IComparer) Sort(Array, IComparer)

使用指定的 Array,排序一維 IComparer 中的元素。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)

使用指定的 Array,排序一維 IComparer 中元素範圍內的元素。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>)

使用指定的 Array,排序 Comparison<T> 中的元素。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>)

使用指定的 Array 泛型介面,排序 IComparer<T> 中的元素。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>)

使用指定的 Array 泛型介面,對 IComparer<T> 中的某個元素範圍內的元素進行排序。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 泛型介面實作,根據第一個 Array 中的索引鍵,排序一對 IComparable<T> 物件 (一個物件包含索引鍵,另一個物件包含對應的項目)。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 泛型介面,根據第一個 Array 中的索引鍵,排序一對 IComparer<T> 物件 (一個物件包含索引鍵,另一個物件包含對應的項目)。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 泛型介面實作,根據第一個 Array 中的索引鍵,排序一對 IComparable<T> 物件中某個範圍的元素 (一個物件包含索引鍵,另一個物件包含對應的項目)。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 泛型介面,根據第一個 Array 中的索引鍵,排序一對 IComparer<T> 物件中某範圍的元素 (一個物件包含索引鍵,另一個物件包含對應的項目)。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)

將項目插入位於指定索引的 IListInserts 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.

適用於

執行緒安全性

此類型的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式,不過,以為Array基礎的 .NET Framework 類別會使用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.

另請參閱