Array 類別

定義

提供建立、操作、搜尋和排序數位的方法,藉此做為 Common Language Runtime 中所有數位的基類。

public ref class Array abstract : System::Collections::IList, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
public ref class Array abstract : ICloneable, System::Collections::IList, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
public ref class Array abstract : ICloneable, System::Collections::IList
public abstract class Array : System.Collections.IList, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
public abstract class Array : ICloneable, System.Collections.IList, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
[System.Serializable]
public abstract class Array : ICloneable, System.Collections.IList
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Array : ICloneable, System.Collections.IList
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Array : ICloneable, System.Collections.IList, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
type Array = class
    interface ICollection
    interface IEnumerable
    interface IList
    interface IStructuralComparable
    interface IStructuralEquatable
type Array = class
    interface ICollection
    interface IEnumerable
    interface IList
    interface IStructuralComparable
    interface IStructuralEquatable
    interface ICloneable
[<System.Serializable>]
type Array = class
    interface ICloneable
    interface IList
    interface ICollection
    interface IEnumerable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Array = class
    interface ICloneable
    interface IList
    interface ICollection
    interface IEnumerable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Array = class
    interface ICloneable
    interface IList
    interface ICollection
    interface IEnumerable
    interface IStructuralComparable
    interface IStructuralEquatable
type Array = class
    interface IList
    interface ICollection
    interface IEnumerable
    interface IStructuralComparable
    interface IStructuralEquatable
Public MustInherit Class Array
Implements IList, IStructuralComparable, IStructuralEquatable
Public MustInherit Class Array
Implements ICloneable, IList, IStructuralComparable, IStructuralEquatable
Public MustInherit Class Array
Implements ICloneable, IList
繼承
Array
屬性
實作

範例

以下程式碼範例說明如何在 Array.Copy 型態為整數的陣列與型別 Object為 的陣列之間複製元素。

open System

let printValues myArr =
    for i in myArr do
        printf $"\t{i}"
    printfn ""

// Creates and initializes a new integer array and a new Object array.
let myIntArray = [| 1..5 |]
let myObjArray = [| 26..30 |]

// Prints the initial values of both arrays.
printfn "Initially,"
printf "integer array:"
printValues myIntArray
printfn "Object array: "
printValues myObjArray

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

// Prints the values of the modified arrays.
printfn "\nAfter copying the first two elements of the integer array to the Object array,"
printf "integer array:"
printValues myIntArray
printf"Object array: "
printValues myObjArray

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

// Prints the values of the modified arrays.
printfn $"\nAfter copying the last two elements of the Object array to the integer array,"
printf "integer array:"
printValues myIntArray
printf "Object array: "
printValues myObjArray


// 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
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 並顯示其屬性與元素。

open System

let printValues (myArray: Array) =
    let mutable i = 0
    let cols = myArray.GetLength(myArray.Rank - 1)
    for item in myArray do
        if i < cols then
            i <- i + 1
        else
            printfn ""
            i <- 1;
        printf $"\t{item}"
    printfn ""

// Creates and initializes a new three-dimensional Array of type int.
let myArr = Array.CreateInstance(typeof<int>, 2, 3, 4)
for i = myArr.GetLowerBound 0 to myArr.GetUpperBound 0 do
    for j = myArr.GetLowerBound 1 to myArr.GetUpperBound 1 do
        for k = myArr.GetLowerBound 2 to myArr.GetUpperBound 2 do
            myArr.SetValue(i * 100 + j * 10 + k, i, j, k)

// Displays the properties of the Array.
printfn $"The Array has {myArr.Rank} dimension(s) and a total of {myArr.Length} elements."
printfn $"\tLength\tLower\tUpper"

for i = 0 to myArr.Rank - 1 do
    printf $"{i}:\t{myArr.GetLength i}"
    printfn $"\t{myArr.GetLowerBound i}\t{myArr.GetUpperBound i}"

// Displays the contents of the Array.
printfn "The Array contains the following values:"
printValues myArr

// 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
// Creates and initializes a new three-dimensional Array of type int.
Array myArr = Array.CreateInstance(typeof(int), 2, 3, 4);
for (int i = myArr.GetLowerBound(0); i <= myArr.GetUpperBound(0); i++)
{
    for (int j = myArr.GetLowerBound(1); j <= myArr.GetUpperBound(1); j++)
    {
        for (int k = myArr.GetLowerBound(2); k <= myArr.GetUpperBound(2); k++)
        {
            myArr.SetValue((i * 100) + (j * 10) + k, i, j, k);
        }
    }
}

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

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

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

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

    Public Shared Sub Main()

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

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

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

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

備註

Array 類別不屬於 System.Collections 命名空間。 然而,它仍被視為集合,因為它基於介面。IList

這個 Array 類別是支援陣列的語言實作的基底類別。 然而,只有系統與編譯器能明確從該 Array 類別衍生。 用戶應採用語言所提供的數組建構。

元素是 中的 Array一個值。 的 Array 長度是它能包含的元素總數。 的 Array 下界是其第一個元素的指標。 An Array 可以有任意下界,但預設下界為零。 當使用 CreateInstance該類別建立實例Array時,可以定義不同的下界。 多維 Array 空間的每個維度可以有不同的界限。 陣列最多可以有32個維度。

與命名空間中的 System.Collections 類別不同,擁有 Array 固定容量。 要增加容量,你必須建立 Array 一個具備所需容量的新物件,將舊 Array 物件的元素複製到新物件,並刪除舊 Array物件。

陣列大小限制為總計 40 億個元素,以及任何指定維度中0X7FEFFFFF的最大索引(0X7FFFFFC7位元組陣列和單一位元組結構的陣列)。

.NET僅限框架:預設情況下,Array 的最大大小為 2 GB。 在 64 位元環境中,你可以透過在執行時環境中將 gcAllowVeryLargeObjects 配置元素的屬性設enabled為 來true避免大小限制。

單維陣列實作 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> 通用介面。 這些實作會在執行時提供給陣列,因此通用介面不會出現在類別的 Array 宣告語法中。 此外,只有將數位轉換成泛型介面類型(明確介面實作),才能存取介面成員的參考主題。 當你將陣列投射到這些介面時,關鍵要注意的是,加入、插入或移除元素的成員會拋出 NotSupportedException

Type 物件提供陣列類型宣告的資訊。 Array 擁有相同陣列類型的物件會共用同一 Type 物件。

Type.IsArrayType.GetElementType 可能無法回傳預期結果, Array 因為若將陣列鑄造為型別 Array,結果是物件而非陣列。 也就是說,返回 typeof(System.Array).IsArray ,返回 typeof(System.Array).GetElementTypenullfalse

Array.Copy 方法不僅複製相同類型陣列間的元素,也能在不同類型的標準陣列間複製;它能自動處理類型鑄造。

有些方法,如 CreateInstanceCopyCopyToGetValueSetValue,提供過載,接受 64 位元整數作為參數,以容納大容量陣列。 LongLengthGetLongLength 回傳 64 位元整數,表示陣列長度。

Array不保證會排序 。 你必須先排序Array,才能執行需要排序的Array操作(例如 BinarySearch)。

在原生程式碼中使用 Array 指標物件並不支援,且會對多個方法拋出 a NotSupportedException

屬性

名稱 Description
IsFixedSize

會得到一個值,表示 是否 Array 具有固定大小。

IsReadOnly

取得值,指出 Array 是否為唯讀。

IsSynchronized

取得值,指出是否同步存取 Array (線程安全)。

Length

得到 所有維度 Array中元素的總數。

LongLength

得到一個 64 位元的整數,代表所有維度 Array中元素的總數。

MaxLength

取得陣列中可包含的元素數目上限。

Rank

得到 的 Array秩(維度數)。 例如,一維陣列會傳回 1、二維陣列傳回 2 等等。

SyncRoot

取得一個物件,可用來同步存取 Array

方法

名稱 Description
AsReadOnly<T>(T[])

傳回指定數位的唯讀包裝函式。

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

利用指定的 IComparer 介面,在一維排序陣列中搜尋一個值。

BinarySearch(Array, Int32, Int32, Object)

利用 IComparable 陣列中每個元素及指定值所實作的介面,在一維排序陣列中搜尋一個值。

BinarySearch(Array, Object, IComparer)

利用指定的 IComparer 介面搜尋整個一維排序陣列中的值。

BinarySearch(Array, Object)

利用 IComparable 陣列中每個元素及指定物件所實作的介面,搜尋整個一維排序陣列中的特定元素。

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

利用指定的 IComparer<T> 通用介面,在一維排序陣列中搜尋一個值。

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

利用 IComparable<T> 由指定值中每個元素 Array 實作的通用介面,在一維排序陣列中搜尋一個值。

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

使用指定的 IComparer<T> 通用介面搜尋整個一維排序陣列中的值。

BinarySearch<T>(T[], T)

利用 IComparable<T> 和 中每個元素 Array 所實作的通用介面,搜尋整個一維排序陣列中的特定元素。

Clear(Array, Int32, Int32)

將陣列中的項目範圍設定為每個元素類型的預設值。

Clear(Array)

清除數位的內容。

Clone()

會建立一個淺層的 Array

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

從指定來源索引起點複製一系列元素 Array ,並貼上到指定目的索引起點的另一個 Array 元素。 保證如果複製未完全成功,則所有變更都會復原。

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

將某個類型的陣列轉換成另一種類型的陣列。

Copy(Array, Array, Int32)

從 從 Array 第一個元素開始複製一系列元素,並貼到從第一個元素開始的另一個 Array 元素中。 長度會指定為32位整數。

Copy(Array, Array, Int64)

從 從 Array 第一個元素開始複製一系列元素,並貼到從第一個元素開始的另一個 Array 元素中。 長度會指定為64位整數。

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

從指定來源索引起點複製一系列元素 Array ,並貼上到指定目的索引起點的另一個 Array 元素。 長度和索引會指定為32位整數。

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

從指定來源索引起點複製一系列元素 Array ,並貼上到指定目的索引起點的另一個 Array 元素。 長度和索引會指定為64位整數。

CopyTo(Array, Int32)

從指定的目的陣列索引開始,將目前一維陣列的所有專案複製到指定的一維陣列。 索引會指定為32位整數。

CopyTo(Array, Int64)

從指定的目的陣列索引開始,將目前一維陣列的所有專案複製到指定的一維陣列。 索引會指定為64位整數。

CreateInstance(Type, Int32, Int32, Int32)

建立指定Type長度與維度長度的三維Array,並採用零為基礎的索引。

CreateInstance(Type, Int32, Int32)

建立指定Type長度與維度長度的二維Array,並採用零為基礎的索引。

CreateInstance(Type, Int32)

建立指定Type長度的一維Array,並以零為基礎的索引。

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

建立指定Type長度與維度長度的多維Array空間,並設定下界。

CreateInstance(Type, Int32[])

建立指定Type長度與維度長度的多維Array度,並以零為基礎的索引。 維度長度是在32位整數的陣列中指定。

CreateInstance(Type, Int64[])

建立指定Type長度與維度長度的多維Array度,並以零為基礎的索引。 維度長度是在64位整數的陣列中指定。

CreateInstanceFromArrayType(Type, Int32)

建立指定陣列類型與長度的一維 Array ,並以零為基礎的索引。

CreateInstanceFromArrayType(Type, Int32[], Int32[])

建立指定Type長度與維度長度的多維Array空間,並設定下界。

CreateInstanceFromArrayType(Type, Int32[])

建立指定Type長度與維度長度的多維Array度,並以零為基礎的索引。

Empty<T>()

傳回空陣列。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Exists<T>(T[], Predicate<T>)

判斷指定的陣列是否包含符合指定述詞所定義條件的專案。

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

將 給定valueT型別 指派給指定元素array中位於(包含)範圍內startIndex且索引數量為count下一數的元素。

Fill<T>(T[], T)

將 給定 valueT 類型 賦予指定 array元素的每個元素。

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

搜尋符合指定謂詞定義條件的元素,並回傳整個 Array中首次出現的元素。

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

擷取符合指定述詞所定義之條件的所有專案。

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

搜尋符合指定謂詞定義條件的元素,並回傳從指定索引開始且包含指定數量元素的元素範圍內首次出現 Array 的零為基礎的索引。

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

搜尋符合指定謂詞定義條件的元素,並回傳從指定索引延伸到最後一個元素範圍內,首次出現 Array 的零為基礎的索引。

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

搜尋符合指定謂詞定義條件的元素,並回傳整個 Array中首次出現的零基索引。

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

搜尋符合指定謂詞定義條件的元素,並回傳整個 Array中最後一次出現的元素。

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

搜尋符合指定謂詞定義條件的元素,並回傳包含指定元素數量且結束於指定索引範圍內最後一次出現 Array 的零為基礎索引。

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

搜尋符合指定謂詞定義條件的元素,並回傳從第一個元素延伸到指定索引範圍內最後一次出現 Array 的零為基礎的索引。

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

搜尋符合指定謂詞定義條件的元素,並回傳整個 Array中最後一次出現的零為基礎索引。

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

對指定數位的每個項目執行指定的動作。

GetEnumerator()

回傳 和 IEnumerator 表示 Array

GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetLength(Int32)

得到一個 32 位元整數,代表 中指定維度 Array內元素的數量。

GetLongLength(Int32)

得到一個 64 位元整數,代表指定維度 Array內元素的數量。

GetLowerBound(Int32)

取得陣列中指定維度之第一個專案的索引。

GetType()

取得目前實例的 Type

(繼承來源 Object)
GetUpperBound(Int32)

取得陣列中指定維度之最後一個專案的索引。

GetValue(Int32, Int32, Int32)

在三維 Array空間中指定位置得到值。 索引會指定為32位整數。

GetValue(Int32, Int32)

在二維 Array中指定位置得到值。 索引會指定為32位整數。

GetValue(Int32)

在一維 Array空間中,得到指定位置的值。 索引會指定為32位整數。

GetValue(Int32[])

在多維 Array空間中指定位置得到值。 索引會指定為32位整數的陣列。

GetValue(Int64, Int64, Int64)

在三維 Array空間中指定位置得到值。 索引會指定為64位整數。

GetValue(Int64, Int64)

在二維 Array中指定位置得到值。 索引會指定為64位整數。

GetValue(Int64)

在一維 Array空間中,得到指定位置的值。 索引會指定為64位整數。

GetValue(Int64[])

在多維 Array空間中指定位置得到值。 索引會指定為64位整數的陣列。

IndexOf(Array, Object, Int32, Int32)

在一維陣列的元素範圍內搜尋指定的物件,並傳回 ifs 第一次出現的 索引。 範圍會從指定的索引延伸至指定的項目數目。

IndexOf(Array, Object, Int32)

在一維陣列的元素範圍內搜尋指定的物件,並傳回其第一次出現的索引。 範圍會從指定的索引延伸至陣列的結尾。

IndexOf(Array, Object)

搜尋指定的物件,並傳回其第一次出現在一維陣列中的索引。

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

在一維陣列的元素範圍內搜尋指定的物件,並傳回其第一次出現的索引。 範圍會從指定的索引延伸至指定的項目數目。

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

在一維陣列的元素範圍內搜尋指定的物件,並傳回其第一次出現的索引。 範圍會從指定的索引延伸至陣列的結尾。

IndexOf<T>(T[], T)

搜尋指定的物件,並傳回其第一次出現在一維陣列中的索引。

Initialize()

透過呼叫該值型別的無參數建構子,初始化該值型態 Array 的每個元素。

LastIndexOf(Array, Object, Int32, Int32)

搜尋指定的物件,並回傳包含指定元素數量且結束於指定索引的一維 Array 元素範圍內最後一次出現的索引。

LastIndexOf(Array, Object, Int32)

搜尋指定的物件,並回傳從第一個元素延伸到指定索引的一維 Array 元素範圍內最後一次出現的索引。

LastIndexOf(Array, Object)

搜尋指定的物件,並回傳整個一維 Array空間中最後一次出現的索引。

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

搜尋指定的物件,並回 Array 傳包含指定元素數量且結束於指定索引範圍內最後一次出現的索引。

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

搜尋指定的物件,並回傳從第一個元素延伸到指定索引範圍內最後一次出現 Array 的索引。

LastIndexOf<T>(T[], T)

搜尋指定物件,並回傳整個 Array內最後一次出現的索引。

MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
Resize<T>(T[], Int32)

將一維數位列的項目數目變更為指定的新大小。

Reverse(Array, Int32, Int32)

反轉一維 Array元素子集的序列。

Reverse(Array)

將整個一維 Array元素的順序顛倒。

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

反轉一維泛型陣列中專案子集的序列。

Reverse<T>(T[])

反轉一維泛型陣列。

SetValue(Object, Int32, Int32, Int32)

將值設定為三維 Array中指定位置的元素。 索引會指定為32位整數。

SetValue(Object, Int32, Int32)

將該元素設定在二維 Array中指定位置的值。 索引會指定為32位整數。

SetValue(Object, Int32)

將該元素設定在一維 Array中指定位置的值。 索引會指定為32位整數。

SetValue(Object, Int32[])

將值設定為多維 Array空間中指定位置的元素。 索引會指定為32位整數的陣列。

SetValue(Object, Int64, Int64, Int64)

將值設定為三維 Array中指定位置的元素。 索引會指定為64位整數。

SetValue(Object, Int64, Int64)

將該元素設定在二維 Array中指定位置的值。 索引會指定為64位整數。

SetValue(Object, Int64)

將該元素設定在一維 Array中指定位置的值。 索引會指定為64位整數。

SetValue(Object, Int64[])

將值設定為多維 Array空間中指定位置的元素。 索引會指定為64位整數的陣列。

Sort(Array, Array, IComparer)

根據第一個物件中的Array鍵,使用指定的 IComparer來排序一對一維Array物件(一個包含鍵,另一個包含對應項目)。

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

根據第一個物件中的Array鍵,使用指定的IComparer鍵,對一維Array物件中的元素進行排序(一個包含鍵,另一個包含對應項目)。

Sort(Array, Array, Int32, Int32)

根據第一個物件中的ArrayIComparable鍵值,根據每個鍵的實作,對一維Array物件中的元素進行排序(一個包含鍵,另一個包含相應項目)。

Sort(Array, Array)

根據第一個ArrayIComparable物件中的鍵數,根據每個鍵的實作,排序一對一維Array物件(一個包含鍵值,另一個包含對應項目)。

Sort(Array, IComparer)

使用指定的 IComparer來排序一維Array元素。

Sort(Array, Int32, Int32, IComparer)

利用指定的 IComparer來排序一維Array元素範圍內的元素。

Sort(Array, Int32, Int32)

利用 IComparable 中每個元素Array的實作,將一維Array元素範圍內的元素排序。

Sort(Array)

利用 IComparable 中每個元素Array的實作,將整個一維Array空間中的元素排序。

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

Array利用指定的 Comparison<T>

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

使用指定的IComparer<T>通用介面來排序元素Array

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

利用指定的IComparer<T>通用介面,將元素排序在元素範圍內Array

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

利用 IComparable<T> 中每個元素Array的通用介面實作,將元素排序於 的元素範圍內Array

Sort<T>(T[])

使用IComparable<T>每個元素Array的通用介面實作來排序整個Array元素。

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

根據第一個Array物件中的鍵,使用指定的IComparer<T>通用介面排序一對Array物件(一個包含鍵,另一個包含相應項目)。

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

根據第一個Array物件中的鍵,使用指定的IComparer<T>通用介面,對一對Array物件中的元素進行排序(一個包含鍵,另一個包含對應項目)。

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

根據第一個ArrayIComparable<T>物件中的鍵數,使用每個鍵的通用介面實作,排序一對Array物件中的元素範圍(一個包含鍵值,另一個包含相應項目)。

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

根據第一個ArrayIComparable<T>物件中的鍵,使用每個鍵的通用介面實作,排序一對Array物件(一個包含鍵,另一個包含相應項目)。

ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)
TrueForAll<T>(T[], Predicate<T>)

判斷陣列中的每個專案是否符合指定述詞所定義的條件。

明確介面實作

名稱 Description
ICollection.Count

得到包含於 的 Array元素數量。

ICollection.IsSynchronized

取得值,這個值表示是否同步存取 Array (安全線程)。

ICollection.SyncRoot

取得一個物件,可用來同步存取 Array

IList.Add(Object)

呼叫此方法總是拋 NotSupportedException 出例外。

IList.Clear()

移除所有項目。IList

IList.Contains(Object)

判斷專案是否在 IList中。

IList.IndexOf(Object)

決定特定項目的 IList索引。

IList.Insert(Int32, Object)

在指定的索引處插入一個項目 IList

IList.IsFixedSize

會得到一個表示是否 Array 固定大小的值。

IList.IsReadOnly

會得到一個值,表示 是否 Array 為唯讀。

IList.Item[Int32]

取得或設定位於指定索引處的專案。

IList.Remove(Object)

移除特定物件 IList首次出現的 。

IList.RemoveAt(Int32)

移除 IList 指定索引的項目。

IStructuralComparable.CompareTo(Object, IComparer)

判斷目前的集合物件在之前、發生於與 相同的位置,或依排序順序追蹤另一個物件。

IStructuralEquatable.Equals(Object, IEqualityComparer)

判斷物件是否等於目前的實例。

IStructuralEquatable.GetHashCode(IEqualityComparer)

傳回目前實例的哈希碼。

擴充方法

名稱 Description
AsParallel(IEnumerable)

啟用查詢的平行處理。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別篩選 IEnumerable 的專案。

適用於

執行緒安全性

此類型的公用靜態 (Shared) 成員是安全線程。 不保證任何實例成員都是安全線程。

此實作未提供同步(執行緒安全)包裝器以Array;然而,基於Array的.NET類別會利用SyncRoot特性提供自己的同步版本集合。

透過集合列舉本質上不是安全線程的程式。 即使集合同步處理,其他線程仍然可以修改集合,這會導致列舉值擲回例外狀況。 若要保證列舉期間的線程安全性,您可以在整個列舉期間鎖定集合,或攔截其他線程所做的變更所產生的例外狀況。

另請參閱