Array Classe

Définition

Fournit des méthodes pour la création, la manipulation, la recherche ainsi que le tri des tableaux et sert de classe de base pour tous les tableaux du 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
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Array = class
    interface ICloneable
    interface ICollection
    interface IList
    interface IEnumerable
    interface IStructuralComparable
    interface IStructuralEquatable
Public MustInherit Class Array
Implements IList, IStructuralComparable, IStructuralEquatable
Public MustInherit Class Array
Implements ICloneable, IList, IStructuralComparable, IStructuralEquatable
Public MustInherit Class Array
Implements ICloneable, IList
Héritage
Array
Attributs
Implémente

Exemples

L’exemple de code suivant montre comment Array.Copy copie des éléments entre un tableau de type entier et un tableau de 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
*/
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

L’exemple de code suivant crée et initialise un Array et affiche ses propriétés et ses éléments.

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
 */
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

Remarques

La Array classe ne fait pas partie des espaces de System.Collections noms. Toutefois, elle est toujours considérée comme une collection, car elle est basée sur l’interface IList .

La Array classe est la classe de base pour les implémentations de langage qui prennent en charge les tableaux. Toutefois, seuls le système et les compilateurs peuvent dériver explicitement de la Array classe . Les utilisateurs doivent utiliser les constructions de tableau fournies par le langage.

Un élément est une valeur dans un Array. La longueur d’un Array correspond au nombre total d’éléments qu’il peut contenir. La limite inférieure d’un Array est l’index de son premier élément. Un Array peut avoir une limite inférieure, mais il a une limite inférieure de zéro par défaut. Une autre limite inférieure peut être définie lors de la création d’une instance de la classe à l’aide ArrayCreateInstancede . Une multidimensionnelle Array peut avoir des limites différentes pour chaque dimension. Un tableau peut avoir un maximum de 32 dimensions.

Contrairement aux classes des espaces de System.Collections noms, Array a une capacité fixe. Pour augmenter la capacité, vous devez créer un nouvel Array objet avec la capacité requise, copier les éléments de l’ancien Array objet vers le nouveau et supprimer l’ancien Array.

La taille du tableau est limitée à un total de 4 milliards d’éléments et à un index maximal de 0X7FEFFFFF dans une dimension donnée (0X7FFFFFC7 pour les tableaux d’octets et les tableaux de structures monooctets).

.NET Framework uniquement : Par défaut, la taille maximale d’un est de Array 2 gigaoctets (Go). Dans un environnement 64 bits, vous pouvez éviter la restriction de taille en définissant l’attribut enabled de l’élément de configuration gcAllowVeryLargeObjects sur true dans l’environnement d’exécution.

Les tableaux unidimensionnels implémentent les System.Collections.Generic.IList<T>interfaces génériques , System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>System.Collections.Generic.IReadOnlyList<T> et System.Collections.Generic.IReadOnlyCollection<T> . Les implémentations sont fournies aux tableaux au moment de l’exécution et, par conséquent, les interfaces génériques n’apparaissent pas dans la syntaxe de déclaration de la Array classe. En outre, il n’existe aucune rubrique de référence pour les membres de l’interface qui n’est accessible qu’en cas de conversion d’un tableau en type d’interface générique (implémentations d’interface explicites). La chose clé à savoir lorsque vous castez un tableau sur l’une de ces interfaces est que les membres qui ajoutent, insèrent ou suppriment des éléments lèvent NotSupportedException.

Type les objets fournissent des informations sur les déclarations de type tableau. Array les objets ayant le même type de tableau partagent le même Type objet.

Type.IsArray et Type.GetElementType peut ne pas retourner les résultats attendus avec Array , car si un tableau est casté en type Array, le résultat est un objet, et non un tableau. Autrement dit, typeof(System.Array).IsArray retourne falseet typeof(System.Array).GetElementType retourne null.

La Array.Copy méthode copie des éléments non seulement entre des tableaux du même type, mais également entre des tableaux standard de types différents ; elle gère automatiquement la conversion de type.

Certaines méthodes, telles que CreateInstance, Copy, CopyTo, GetValueet SetValue, fournissent des surcharges qui acceptent des entiers 64 bits en tant que paramètres pour prendre en charge les tableaux de grande capacité. LongLength et GetLongLength retournent des entiers 64 bits indiquant la longueur du tableau.

Le Array n’est pas garanti pour être trié. Vous devez trier le Array avant d’effectuer des opérations (telles que BinarySearch) qui nécessitent le Array pour être trié.

L’utilisation d’un Array objet de pointeurs dans le code natif n’est pas prise en charge et génère un NotSupportedException pour plusieurs méthodes.

Propriétés

IsFixedSize

Obtient une valeur indiquant si Array est de taille fixe.

IsReadOnly

Obtient une valeur indiquant si Array est en lecture seule.

IsSynchronized

Obtient une valeur indiquant si l’accès à Array est synchronisé (thread-safe).

Length

Obtient le nombre total d’éléments dans toutes les dimensions du Array.

LongLength

Obtient un entier 64 bits qui représente le nombre total d’éléments dans toutes les dimensions du Array.

MaxLength

Obtient le nombre maximal d’éléments pouvant être contenus dans un tableau.

Rank

Obtient le rang (nombre de dimensions) du Array. Par exemple, un tableau unidimensionnel retourne 1, un tableau bidimensionnel retourne 2, etc.

SyncRoot

Obtient un objet qui peut être utilisé pour synchroniser l’accès à Array.

Méthodes

AsReadOnly<T>(T[])

Retourne un wrapper en lecture seule pour le tableau spécifié.

BinarySearch(Array, Int32, Int32, Object)

Recherche une valeur dans une plage d’éléments d’un tableau trié unidimensionnel, à l’aide de l’interface IComparable implémentée par chaque élément du tableau et par la valeur spécifiée.

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

Recherche une valeur dans une plage d’éléments d’un tableau trié unidimensionnel à l’aide de l’interface IComparer spécifiée.

BinarySearch(Array, Object)

Recherche un élément spécifique dans tout un tableau trié unidimensionnel, à l’aide de l’interface IComparable implémentée par chaque élément du tableau et par l’objet spécifié.

BinarySearch(Array, Object, IComparer)

Recherche une valeur dans l’intégralité d’un tableau trié unidimensionnel, à l’aide de l’interface IComparer spécifiée.

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

Recherche une valeur dans une plage d’éléments d’un tableau trié unidimensionnel, à l’aide de l’interface générique IComparable<T> implémentée par chaque élément de Array et par la valeur spécifiée.

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

Recherche une valeur dans une plage d’éléments d’un tableau trié unidimensionnel, à l’aide de l’interface générique IComparer<T> spécifiée.

BinarySearch<T>(T[], T)

Recherche un élément spécifique dans un tableau entier trié unidimensionnel, à l’aide de l’interface générique IComparable<T> implémentée par chaque élément de Array et par l’objet spécifié.

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

Recherche une valeur dans l’intégralité d’un tableau trié unidimensionnel, à l’aide de l’interface générique IComparer<T> spécifiée.

Clear(Array)

Efface le contenu d’un tableau.

Clear(Array, Int32, Int32)

Définit une plage d'éléments dans un tableau à la valeur par défaut de chaque type d'élément.

Clone()

Crée une copie superficielle de Array.

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

Copie une plage d’éléments à partir d’un Array commençant à l’index source spécifié et les colle dans un autre Array commençant à l’index de destination spécifié. Garantit que toutes les modifications sont annulées si la copie ne se déroule pas intégralement avec succès.

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

Convertit un tableau d'un type en un tableau d'un autre type.

Copy(Array, Array, Int32)

Copie une série d’éléments de Array en commençant au premier élément, et les colle dans un autre Array en commençant au premier élément. La longueur est spécifiée sous forme d'un entier 32 bits.

Copy(Array, Array, Int64)

Copie une série d’éléments de Array en commençant au premier élément, et les colle dans un autre Array en commençant au premier élément. La longueur est spécifiée sous forme d'un entier 64 bits.

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

Copie une plage d’éléments à partir d’un Array commençant à l’index source spécifié et les colle dans un autre Array commençant à l’index de destination spécifié. La longueur et les index sont spécifiés en tant qu’entiers 32 bits.

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

Copie une plage d’éléments à partir d’un Array commençant à l’index source spécifié et les colle dans un autre Array commençant à l’index de destination spécifié. La longueur et les index sont spécifiés en tant qu’entiers 64 bits.

CopyTo(Array, Int32)

Copie tous les éléments du tableau unidimensionnel actuel dans le tableau unidimensionnel spécifié en commençant à l'index du tableau de destination spécifié. L'index est spécifié en tant qu'entier 32 bits.

CopyTo(Array, Int64)

Copie tous les éléments du tableau unidimensionnel actuel dans le tableau unidimensionnel spécifié en commençant à l'index du tableau de destination spécifié. L'index est spécifié en tant qu'entier 64 bits.

CreateInstance(Type, Int32)

Crée un Array unidimensionnel du Type et de la longueur spécifiés, à l’aide d’un index de base zéro.

CreateInstance(Type, Int32, Int32)

Crée un Array à deux dimensions du Type et des longueurs de dimensions spécifiés, à l’aide d’un index de base zéro.

CreateInstance(Type, Int32, Int32, Int32)

Crée un Array à trois dimensions du Type et des longueurs de dimensions spécifiés, à l’aide d’un index de base zéro.

CreateInstance(Type, Int32[])

Crée un Array multidimensionnel du Type et des longueurs de dimensions spécifiés, à l’aide d’un index de base zéro. Les longueurs de dimensions sont spécifiées en tant qu'entiers 32 bits.

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

Crée un Array multidimensionnel du Type et des longueurs de dimensions spécifiés, avec les limites inférieures déterminées.

CreateInstance(Type, Int64[])

Crée un Array multidimensionnel du Type et des longueurs de dimensions spécifiés, à l’aide d’un index de base zéro. Les longueurs de dimensions sont spécifiées en tant qu'entiers 64 bits.

Empty<T>()

Retourne un tableau vide.

Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.

(Hérité de Object)
Exists<T>(T[], Predicate<T>)

Détermine si le tableau spécifié contient des éléments qui correspondent aux conditions définies par le prédicat spécifié.

Fill<T>(T[], T)

Assigne la value donnée de type T à chaque élément du array spécifié.

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

Assigne la value donnée de type T aux éléments du array spécifié qui se trouvent dans la plage de startIndex (inclusif) et du nombre count d’index suivants.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne la première occurrence dans le Array entier.

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

Récupère tous les éléments qui correspondent aux conditions définies par le prédicat spécifié.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne l'index de base zéro de la première occurrence trouvée dans la plage d'éléments de Array qui commence à l'index spécifié et contient le nombre d'éléments spécifié.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne l'index de base zéro de la première occurrence trouvée dans la plage d'éléments de Array qui s'étend de l'index spécifié au dernier élément.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne l'index de base zéro de la première occurrence trouvée dans le Array entier.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne la dernière occurrence dans le Array entier.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne l’index de base zéro de la dernière occurrence trouvée dans la plage d’éléments du Array qui contient le nombre d’éléments spécifié et se termine à l’index spécifié.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne l'index de base zéro de la dernière occurrence trouvée dans la plage d'éléments du Array qui s'étend du premier élément à l'index spécifié.

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

Recherche un élément qui correspond aux conditions définies par le prédicat spécifié et retourne l'index de base zéro de la dernière occurrence trouvée dans le Array entier.

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

Exécute l'action spécifiée sur chaque élément du tableau spécifié.

GetEnumerator()

Retourne IEnumerator pour l'objet Array.

GetHashCode()

Fait office de fonction de hachage par défaut.

(Hérité de Object)
GetLength(Int32)

Obtient un entier 32 bits qui représente le nombre d’éléments dans la dimension spécifiée de Array.

GetLongLength(Int32)

Obtient un entier 64 bits qui représente le nombre d’éléments dans la dimension spécifiée de Array.

GetLowerBound(Int32)

Obtient l'index du premier élément de la dimension spécifiée dans le tableau.

GetType()

Obtient le Type de l'instance actuelle.

(Hérité de Object)
GetUpperBound(Int32)

Obtient l'index du dernier élément de la dimension spécifiée dans le tableau.

GetValue(Int32)

Obtient la valeur à la position spécifiée de l’Array unidimensionnel. L'index est spécifié en tant qu'entier 32 bits.

GetValue(Int32, Int32)

Obtient la valeur à la position spécifiée du Array à deux dimensions. Les index sont spécifiés en tant qu’entiers 32 bits.

GetValue(Int32, Int32, Int32)

Obtient la valeur à la position spécifiée du Array à trois dimensions. Les index sont spécifiés en tant qu’entiers 32 bits.

GetValue(Int32[])

Obtient la valeur à la position spécifiée du Array multidimensionnel. Les index sont spécifiés sous la forme d'un tableau d'entiers 32 bits.

GetValue(Int64)

Obtient la valeur à la position spécifiée de l’Array unidimensionnel. L'index est spécifié en tant qu'entier 64 bits.

GetValue(Int64, Int64)

Obtient la valeur à la position spécifiée du Array à deux dimensions. Les index sont spécifiés en tant qu'entiers 64 bits.

GetValue(Int64, Int64, Int64)

Obtient la valeur à la position spécifiée du Array à trois dimensions. Les index sont spécifiés en tant qu'entiers 64 bits.

GetValue(Int64[])

Obtient la valeur à la position spécifiée du Array multidimensionnel. Les index sont spécifiés sous la forme d'un tableau d'entiers 64 bits.

IndexOf(Array, Object)

Recherche l'objet spécifié et retourne l'index de sa première occurrence dans un tableau unidimensionnel.

IndexOf(Array, Object, Int32)

Recherche l’objet spécifié dans une plage d’éléments d’un tableau unidimensionnel, et retourne l’index de sa première occurrence. La plage s’étend d’un index spécifié à la fin du tableau.

IndexOf(Array, Object, Int32, Int32)

Recherche l'objet spécifié dans une plage d'éléments d'un tableau unidimensionnel, et retourne l'index de sa première occurrence. La plage commence à un index spécifié pour un nombre d'éléments spécifié.

IndexOf<T>(T[], T)

Recherche l'objet spécifié et retourne l'index de sa première occurrence dans un tableau unidimensionnel.

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

Recherche l’objet spécifié dans une plage d’éléments d’un tableau unidimensionnel, et retourne l’index de sa première occurrence. La plage s’étend d’un index spécifié à la fin du tableau.

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

Recherche l’objet spécifié dans une plage d’éléments d’un tableau unidimensionnel, et retourne l’index de sa première occurrence. La plage commence à un index spécifié pour un nombre d'éléments spécifié.

Initialize()

Initialise tous les éléments du type valeur Array en appelant le constructeur sans paramètre du type valeur.

LastIndexOf(Array, Object)

Recherche l’objet spécifié et retourne l’index de la dernière occurrence dans l’ensemble du Array unidimensionnel.

LastIndexOf(Array, Object, Int32)

Recherche l’objet spécifié et retourne l’index de la dernière occurrence dans la plage d’éléments du Array unidimensionnel qui s’étend du premier élément jusqu’à l’index spécifié.

LastIndexOf(Array, Object, Int32, Int32)

Recherche l’objet spécifié et retourne l’index de la dernière occurrence au sein de la plage d’éléments du Array unidimensionnel qui contient le nombre d’éléments spécifié et se termine à l’index spécifié.

LastIndexOf<T>(T[], T)

Recherche l’objet spécifié et retourne l’index de la dernière occurrence dans le Array entier.

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

Recherche l’objet spécifié et retourne l’index de la dernière occurrence dans la plage d’éléments du Array qui s’étend du premier élément jusqu’à l’index spécifié.

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

Recherche l’objet spécifié et retourne l’index de la dernière occurrence dans la plage d’éléments de l’Array qui contient le nombre d’éléments spécifié et se termine à l’index spécifié.

MemberwiseClone()

Crée une copie superficielle du Object actuel.

(Hérité de Object)
Resize<T>(T[], Int32)

Modifie le nombre d’éléments d’un tableau unidimensionnel avec la nouvelle taille spécifiée.

Reverse(Array)

Extrait la séquence des éléments de l’intégralité du Array unidimensionnel.

Reverse(Array, Int32, Int32)

Extrait la séquence d’un sous-ensemble des éléments du Array unidimensionnel.

Reverse<T>(T[])

Inverse la séquence des éléments dans le tableau générique unidimensionnel.

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

Inverse la séquence d’un sous-ensemble des éléments dans le tableau générique unidimensionnel.

SetValue(Object, Int32)

Affecte une valeur à l’élément à la position spécifiée du Array unidimensionnel. L'index est spécifié en tant qu'entier 32 bits.

SetValue(Object, Int32, Int32)

Affecte une valeur à l’élément à la position spécifiée du Array à deux dimensions. Les index sont spécifiés en tant qu’entiers 32 bits.

SetValue(Object, Int32, Int32, Int32)

Affecte une valeur à l’élément à la position spécifiée du Array à trois dimensions. Les index sont spécifiés en tant qu’entiers 32 bits.

SetValue(Object, Int32[])

Affecte une valeur à l’élément à la position spécifiée du Array multidimensionnel. Les index sont spécifiés sous la forme d'un tableau d'entiers 32 bits.

SetValue(Object, Int64)

Affecte une valeur à l’élément à la position spécifiée du Array unidimensionnel. L'index est spécifié en tant qu'entier 64 bits.

SetValue(Object, Int64, Int64)

Affecte une valeur à l’élément à la position spécifiée du Array à deux dimensions. Les index sont spécifiés en tant qu'entiers 64 bits.

SetValue(Object, Int64, Int64, Int64)

Affecte une valeur à l’élément à la position spécifiée du Array à trois dimensions. Les index sont spécifiés en tant qu'entiers 64 bits.

SetValue(Object, Int64[])

Affecte une valeur à l’élément à la position spécifiée du Array multidimensionnel. Les index sont spécifiés sous la forme d'un tableau d'entiers 64 bits.

Sort(Array)

Trie les éléments dans l’intégralité d’un Array unidimensionnel à l’aide de l’implémentation IComparable de chaque élément du Array.

Sort(Array, Array)

Trie une paire d’objets Array unidimensionnels (l’un contient les clés et l’autre, les éléments correspondants) en fonction des clés du premier Array à l’aide de l’implémentation de IComparable de chaque clé.

Sort(Array, Array, IComparer)

Trie une paire d’objets Array unidimensionnels (l’un contient les clés et l’autre les éléments correspondants) en fonction des clés du premier Array à l’aide de l’objet IComparer spécifié.

Sort(Array, Array, Int32, Int32)

Trie une plage d’éléments dans une paire d’objets Array unidimensionnels (l’un contient les clés et l’autre, les éléments correspondants) en fonction des clés du premier Array à l’aide de l’implémentation IComparable de chaque clé.

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

Trie une plage d’éléments dans une paire d’objets Array unidimensionnels (l’un contient les clés et l’autre, les éléments correspondants) en fonction des clés du premier Array à l’aide de l’objet IComparer spécifié.

Sort(Array, IComparer)

Trie les éléments d’un Array unidimensionnel à l’aide de l’objet IComparer spécifié.

Sort(Array, Int32, Int32)

Trie les éléments d’une plage d’éléments d’un Array unidimensionnel à l’aide de l’implémentation IComparable de chaque élément de l’Array.

Sort(Array, Int32, Int32, IComparer)

Trie les éléments d’une plage d’éléments d’un Array unidimensionnel à l’aide du IComparer spécifié.

Sort<T>(T[])

Trie les éléments dans l’intégralité d’un Array à l’aide de l’implémentation de l’interface générique IComparable<T> de chaque élément du Array.

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

Trie les éléments inclus dans un Array à l’aide de l’objet Comparison<T> spécifié.

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

Trie les éléments dans un Array à l’aide de l’interface générique IComparer<T> spécifiée.

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

Trie les éléments d’une plage d’éléments d’un Array à l’aide de l’implémentation de l’interface générique IComparable<T> de chaque élément de Array.

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

Trie les éléments d’une plage d’éléments dans un Array à l’aide de l’interface générique IComparer<T> spécifiée.

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

Trie une paire d’objets Array (l’un contient les clés et l’autre, les éléments correspondants) en fonction des clés du premier Array à l’aide de l’implémentation de l’interface générique IComparable<T> de chaque clé.

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

Trie une paire d’objets Array (l’un contient les clés et l’autre, les éléments correspondants) en fonction des clés du premier Array à l’aide de l’interface générique IComparer<T> spécifiée.

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

Trie une plage d’éléments dans une paire d’objets Array (l’un contient les clés et l’autre, les éléments correspondants) en fonction des clés du premier Array à l’aide de l’implémentation d’interface générique IComparable<T> de chaque clé.

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

Trie une plage d’éléments dans une paire d’objets Array (l’un contient les clés et l’autre, les éléments correspondants) en fonction des clés du premier Array à l’aide de l’interface générique IComparer<T> spécifiée.

ToString()

Retourne une chaîne qui représente l'objet actuel.

(Hérité de Object)
TrueForAll<T>(T[], Predicate<T>)

Détermine si chaque élément dans le tableau correspond aux conditions définies par le prédicat spécifié.

Implémentations d’interfaces explicites

ICollection.Count

Obtient le nombre d’éléments contenus dans le Array.

ICollection.IsSynchronized

Obtient une valeur qui indique si l’accès à Array est synchronisé (thread safe).

ICollection.SyncRoot

Obtient un objet qui peut être utilisé pour synchroniser l’accès à Array.

IList.Add(Object)

L’appel de cette méthode lève toujours une exception NotSupportedException.

IList.Clear()

Supprime tous les éléments de IList.

IList.Contains(Object)

Détermine si le IList contient un élément.

IList.IndexOf(Object)

Détermine l'index d'un élément spécifique d'IList.

IList.Insert(Int32, Object)

Insère un élément dans IList à l’index spécifié.

IList.IsFixedSize

Obtient une valeur qui indique si Array est de taille fixe.

IList.IsReadOnly

Obtient une valeur qui indique si l’objet Array est en lecture seule.

IList.Item[Int32]

Obtient ou définit l'élément au niveau de l'index spécifié.

IList.Remove(Object)

Supprime la première occurrence d’un objet spécifique de IList.

IList.RemoveAt(Int32)

Supprime l'élément IList au niveau de l'index spécifié.

IStructuralComparable.CompareTo(Object, IComparer)

Détermine si l'objet collection actuel précède, se situe à la même position que, ou suit un autre objet dans l'ordre de tri.

IStructuralEquatable.Equals(Object, IEqualityComparer)

Détermine si un objet est identique à l'instance actuelle.

IStructuralEquatable.GetHashCode(IEqualityComparer)

Retourne un code de hachage pour l'instance actuelle.

Méthodes d’extension

Cast<TResult>(IEnumerable)

Effectue un cast des éléments d'un IEnumerable vers le type spécifié.

OfType<TResult>(IEnumerable)

Filtre les éléments d'un IEnumerable en fonction du type spécifié.

AsParallel(IEnumerable)

Active la parallélisation d'une requête.

AsQueryable(IEnumerable)

Convertit un IEnumerable en IQueryable.

S’applique à

Cohérence de thread

Les membres statiques publics (Shared en Visual Basic) de ce type sont thread safe. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

Cette implémentation ne fournit pas de wrapper synchronisé (thread safe) pour un Array; toutefois, les classes .NET basées sur Array fournissent leur propre version synchronisée de la collection à l’aide de la SyncRoot propriété .

L'énumération d'une collection n'est intrinsèquement pas une procédure thread-safe. Même lorsqu'une collection est synchronisée, les autres threads peuvent toujours la modifier, ce qui entraîne la levée d'une exception par l'énumérateur. Pour garantir la sécurité des threads au cours de l’énumération, vous pouvez verrouiller la collection pendant l’ensemble de l’énumération ou bien intercepter les exceptions résultant des modifications apportées par les autres threads.

Voir aussi