Marshal.Copy Método

Definición

Copia datos de una matriz administrada en un puntero de memoria no administrado o desde un puntero de memoria no administrado a una matriz administrada.

Sobrecargas

Nombre Description
Copy(Single[], Int32, IntPtr, Int32)

Copia datos de una matriz de números de punto flotante de precisión sencilla administrada unidimensional a un puntero de memoria no administrado.

Copy(IntPtr[], Int32, IntPtr, Int32)

Copia datos de una matriz administrada IntPtr unidimensional a un puntero de memoria no administrado.

Copy(IntPtr, IntPtr[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz administrada IntPtr .

Copy(IntPtr, Int64[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 64 bits con signo administrado.

Copy(IntPtr, Int32[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 32 bits con signo administrado.

Copy(IntPtr, Int16[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 16 bits con signo administrada.

Copy(IntPtr, Double[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de números de punto flotante de precisión doble administrada.

Copy(IntPtr, Single[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de números de punto flotante de precisión única administrada.

Copy(IntPtr, Byte[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 8 bits sin signo administrada.

Copy(Int64[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 64 bits con signo de 64 bits administrados a un puntero de memoria no administrado.

Copy(Int32[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 32 bits con signo de 32 bits administrados a un puntero de memoria no administrado.

Copy(Int16[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 16 bits con signo de 16 bits administrados a un puntero de memoria no administrado.

Copy(Double[], Int32, IntPtr, Int32)

Copia datos de una matriz de números de punto flotante de precisión doble administrada unidimensional a un puntero de memoria no administrado.

Copy(IntPtr, Char[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de caracteres administrados.

Copy(Char[], Int32, IntPtr, Int32)

Copia datos de una matriz de caracteres administrados unidimensional a un puntero de memoria no administrado.

Copy(Byte[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 8 bits sin signo administrados unidimensionales a un puntero de memoria no administrado.

Copy(Single[], Int32, IntPtr, Int32)

Copia datos de una matriz de números de punto flotante de precisión sencilla administrada unidimensional a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <float> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(float[] source, int startIndex, IntPtr destination, int length);
public static void Copy(float[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : single[] * int * nativeint * int -> unit
static member Copy : single[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As Single(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source
Single[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

startIndex y length no son válidos.

source, startIndex, destinationo length es null.

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada unidimensional en una matriz de estilo C no administrada.

Se aplica a

Copy(IntPtr[], Int32, IntPtr, Int32)

Copia datos de una matriz administrada IntPtr unidimensional a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <IntPtr> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr[] source, int startIndex, IntPtr destination, int length);
public static void Copy(IntPtr[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint[] * int * nativeint * int -> unit
static member Copy : nativeint[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As IntPtr(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source

IntPtr[]

nativeint[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada IntPtr unidimensional en una matriz de estilo C no administrada.

Se aplica a

Copy(IntPtr, IntPtr[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz administrada IntPtr .

public:
 static void Copy(IntPtr source, cli::array <IntPtr> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, IntPtr[] destination, int startIndex, int length);
public static void Copy(IntPtr source, IntPtr[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * nativeint[] * int * int -> unit
static member Copy : nativeint * nativeint[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As IntPtr(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination

IntPtr[]

nativeint[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados que corresponden al source parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar al Marshal.Copy método .

Se aplica a

Copy(IntPtr, Int64[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 64 bits con signo administrado.

public:
 static void Copy(IntPtr source, cli::array <long> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, long[] destination, int startIndex, int length);
public static void Copy(IntPtr source, long[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * int64[] * int * int -> unit
static member Copy : nativeint * int64[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As Long(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination
Int64[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        Int64[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            Int64[] managedArray2 = new Int64[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Int64() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Int64

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados correspondientes alsource parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar a este método.

Consulte también

Se aplica a

Copy(IntPtr, Int32[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 32 bits con signo administrado.

public:
 static void Copy(IntPtr source, cli::array <int> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, int[] destination, int startIndex, int length);
public static void Copy(IntPtr source, int[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * int[] * int * int -> unit
static member Copy : nativeint * int[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As Integer(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination
Int32[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        int[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            int[] managedArray2 = new int[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Integer() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Integer

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados correspondientes al source parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar a este método.

Consulte también

Se aplica a

Copy(IntPtr, Int16[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 16 bits con signo administrada.

public:
 static void Copy(IntPtr source, cli::array <short> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, short[] destination, int startIndex, int length);
public static void Copy(IntPtr source, short[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * int16[] * int * int -> unit
static member Copy : nativeint * int16[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As Short(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination
Int16[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        short[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            short[] managedArray2 = new short[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Short() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Short

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados correspondientes al source parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar a este método.

Consulte también

Se aplica a

Copy(IntPtr, Double[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de números de punto flotante de precisión doble administrada.

public:
 static void Copy(IntPtr source, cli::array <double> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, double[] destination, int startIndex, int length);
public static void Copy(IntPtr source, double[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * double[] * int * int -> unit
static member Copy : nativeint * double[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As Double(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination
Double[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        double[] managedArray = { 0.1, 0.2, 0.3, 0.4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            double[] managedArray2 = new double[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Double() = {0.1, 0.2, 0.3, 0.4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Double

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados correspondientes al source parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar a este método.

Consulte también

Se aplica a

Copy(IntPtr, Single[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de números de punto flotante de precisión única administrada.

public:
 static void Copy(IntPtr source, cli::array <float> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, float[] destination, int startIndex, int length);
public static void Copy(IntPtr source, float[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * single[] * int * int -> unit
static member Copy : nativeint * single[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As Single(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination
Single[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados correspondientes al source parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar a este método.

Consulte también

Se aplica a

Copy(IntPtr, Byte[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de enteros de 8 bits sin signo administrada.

public:
 static void Copy(IntPtr source, cli::array <System::Byte> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, byte[] destination, int startIndex, int length);
public static void Copy(IntPtr source, byte[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * byte[] * int * int -> unit
static member Copy : nativeint * byte[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As Byte(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination
Byte[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        byte[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            byte[] managedArray2 = new byte[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Byte() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Byte

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados correspondientes al source parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar a este método.

Consulte también

Se aplica a

Copy(Int64[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 64 bits con signo de 64 bits administrados a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <long> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(long[] source, int startIndex, IntPtr destination, int length);
public static void Copy(long[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : int64[] * int * nativeint * int -> unit
static member Copy : int64[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As Long(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source
Int64[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

startIndex y length no son válidos.

source, startIndex, destinationo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        Int64[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            Int64[] managedArray2 = new Int64[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Int64() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Int64

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada unidimensional en una matriz de estilo C no administrada.

Se aplica a

Copy(Int32[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 32 bits con signo de 32 bits administrados a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <int> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(int[] source, int startIndex, IntPtr destination, int length);
public static void Copy(int[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : int[] * int * nativeint * int -> unit
static member Copy : int[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As Integer(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source
Int32[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

startIndex y length no son válidos.

startIndex o length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        int[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            int[] managedArray2 = new int[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Integer() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Integer

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada unidimensional en una matriz de estilo C no administrada.

Se aplica a

Copy(Int16[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 16 bits con signo de 16 bits administrados a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <short> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(short[] source, int startIndex, IntPtr destination, int length);
public static void Copy(short[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : int16[] * int * nativeint * int -> unit
static member Copy : int16[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As Short(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source
Int16[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

startIndex y length no son válidos.

source, startIndex, destinationo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        short[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            short[] managedArray2 = new short[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Short() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Short

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada unidimensional en una matriz de estilo C no administrada.

Se aplica a

Copy(Double[], Int32, IntPtr, Int32)

Copia datos de una matriz de números de punto flotante de precisión doble administrada unidimensional a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <double> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(double[] source, int startIndex, IntPtr destination, int length);
public static void Copy(double[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : double[] * int * nativeint * int -> unit
static member Copy : double[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As Double(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source
Double[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

startIndex y length no son válidos.

source, startIndex, destinationo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        double[] managedArray = { 0.1, 0.2, 0.3, 0.4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            double[] managedArray2 = new double[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Double() = {0.1, 0.2, 0.3, 0.4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Double

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada unidimensional en una matriz de estilo C no administrada.

Se aplica a

Copy(IntPtr, Char[], Int32, Int32)

Copia datos de un puntero de memoria no administrado a una matriz de caracteres administrados.

public:
 static void Copy(IntPtr source, cli::array <char> ^ destination, int startIndex, int length);
[System.Security.SecurityCritical]
public static void Copy(IntPtr source, char[] destination, int startIndex, int length);
public static void Copy(IntPtr source, char[] destination, int startIndex, int length);
[<System.Security.SecurityCritical>]
static member Copy : nativeint * char[] * int * int -> unit
static member Copy : nativeint * char[] * int * int -> unit
Public Shared Sub Copy (source As IntPtr, destination As Char(), startIndex As Integer, length As Integer)

Parámetros

source
IntPtr

nativeint

Puntero de memoria desde el que se va a copiar.

destination
Char[]

Matriz a la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de destino donde se debe iniciar la copia.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

source, destination, startIndexo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

// Remember that the actual size of System.Char in unmanaged memory is 2.
using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        char[] managedArray = new char[1000];
        managedArray[0] = 'a';
        managedArray[1] = 'b';
        managedArray[2] = 'c';
        managedArray[3] = 'd';
        managedArray[999] = 'Z';

        // Initialize unmanaged memory to hold the array.
        // int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;  // Incorrect
        int size = Marshal.SystemDefaultCharSize * managedArray.Length;       // Correct

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            char[] managedArray2 = new char[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);
            Console.WriteLine("Here is the roundtripped array: {0} {1} {2} {3} {4}",
                               managedArray2[0], managedArray2[1], managedArray2[2], managedArray2[3],
                               managedArray2[999]);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
' Remember that the actual size of System.Char in unmanaged memory is 2.

Imports System.Runtime.InteropServices



Module Module1

    Sub Main()
        ' Create a managed array.
        Dim managedArray As Char() = New Char(999) {}
        managedArray(0) = "a"c
        managedArray(1) = "b"c
        managedArray(2) = "c"c
        managedArray(3) = "d"c
        managedArray(999) = "Z"c

        ' Initialize unmanaged memory to hold the array.
        ' Dim size As Integer = Marshal.SizeOf(managedArray[0]) * managedArray.Length;  ' Incorrect
        Dim size As Integer = Marshal.SystemDefaultCharSize * managedArray.Length       ' Correct

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.

            Dim managedArray2 As Char() = New Char(managedArray.Length - 1) {}

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)
            Console.WriteLine("Here is the roundtripped array: {0} {1} {2} {3} {4}", managedArray2(0), managedArray2(1), managedArray2(2), managedArray2(3), managedArray2(999))


            Console.WriteLine("The array was copied to unmanaged memory and back.")
        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)

        End Try
    End Sub
End Module

Comentarios

Las matrices de estilo C no administradas no contienen información de límites, lo que impide que se validen los startIndex parámetros y length . Por lo tanto, los datos no administrados correspondientes al source parámetro rellenan la matriz administrada independientemente de su utilidad. Debe inicializar la matriz administrada con el tamaño adecuado antes de llamar a este método.

Consulte también

Se aplica a

Copy(Char[], Int32, IntPtr, Int32)

Copia datos de una matriz de caracteres administrados unidimensional a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <char> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(char[] source, int startIndex, IntPtr destination, int length);
public static void Copy(char[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : char[] * int * nativeint * int -> unit
static member Copy : char[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As Char(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source
Char[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

startIndex y length no son válidos.

startIndex, destinationo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada y, a continuación, se copia la matriz no administrada en la memoria administrada.

// Remember that the actual size of System.Char in unmanaged memory is 2.
using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        char[] managedArray = new char[1000];
        managedArray[0] = 'a';
        managedArray[1] = 'b';
        managedArray[2] = 'c';
        managedArray[3] = 'd';
        managedArray[999] = 'Z';

        // Initialize unmanaged memory to hold the array.
        // int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;  // Incorrect
        int size = Marshal.SystemDefaultCharSize * managedArray.Length;       // Correct

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            char[] managedArray2 = new char[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);
            Console.WriteLine("Here is the roundtripped array: {0} {1} {2} {3} {4}",
                               managedArray2[0], managedArray2[1], managedArray2[2], managedArray2[3],
                               managedArray2[999]);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
' Remember that the actual size of System.Char in unmanaged memory is 2.

Imports System.Runtime.InteropServices



Module Module1

    Sub Main()
        ' Create a managed array.
        Dim managedArray As Char() = New Char(999) {}
        managedArray(0) = "a"c
        managedArray(1) = "b"c
        managedArray(2) = "c"c
        managedArray(3) = "d"c
        managedArray(999) = "Z"c

        ' Initialize unmanaged memory to hold the array.
        ' Dim size As Integer = Marshal.SizeOf(managedArray[0]) * managedArray.Length;  ' Incorrect
        Dim size As Integer = Marshal.SystemDefaultCharSize * managedArray.Length       ' Correct

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.

            Dim managedArray2 As Char() = New Char(managedArray.Length - 1) {}

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)
            Console.WriteLine("Here is the roundtripped array: {0} {1} {2} {3} {4}", managedArray2(0), managedArray2(1), managedArray2(2), managedArray2(3), managedArray2(999))


            Console.WriteLine("The array was copied to unmanaged memory and back.")
        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)

        End Try
    End Sub
End Module

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada unidimensional en una matriz de estilo C no administrada.

Se aplica a

Copy(Byte[], Int32, IntPtr, Int32)

Copia datos de una matriz de enteros de 8 bits sin signo administrados unidimensionales a un puntero de memoria no administrado.

public:
 static void Copy(cli::array <System::Byte> ^ source, int startIndex, IntPtr destination, int length);
[System.Security.SecurityCritical]
public static void Copy(byte[] source, int startIndex, IntPtr destination, int length);
public static void Copy(byte[] source, int startIndex, IntPtr destination, int length);
[<System.Security.SecurityCritical>]
static member Copy : byte[] * int * nativeint * int -> unit
static member Copy : byte[] * int * nativeint * int -> unit
Public Shared Sub Copy (source As Byte(), startIndex As Integer, destination As IntPtr, length As Integer)

Parámetros

source
Byte[]

Matriz unidimensional desde la que se va a copiar.

startIndex
Int32

Índice de base cero en la matriz de origen donde se debe iniciar la copia.

destination
IntPtr

nativeint

Puntero de memoria al que se va a copiar.

length
Int32

Número de elementos de matriz que se van a copiar.

Atributos

Excepciones

startIndex y length no son válidos.

source, startIndex, destinationo length es null.

Ejemplos

En el ejemplo siguiente se copia una matriz en memoria no administrada mediante la Copy(Byte[], Int32, IntPtr, Int32) sobrecarga y, a continuación, se copia la matriz no administrada en la memoria administrada mediante la Copy(IntPtr, Byte[], Int32, Int32) sobrecarga.

using System;
using System.Runtime.InteropServices;

class Example
{

    static void Main()
    {
        // Create a managed array.
        byte[] managedArray = { 1, 2, 3, 4 };

        // Initialize unmanaged memory to hold the array.
        int size = Marshal.SizeOf(managedArray[0]) * managedArray.Length;

        IntPtr pnt = Marshal.AllocHGlobal(size);

        try
        {
            // Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length);

            // Copy the unmanaged array back to another managed array.

            byte[] managedArray2 = new byte[managedArray.Length];

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length);

            Console.WriteLine("The array was copied to unmanaged memory and back.");
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt);
        }
    }
}
Imports System.Runtime.InteropServices



Module Example


    Sub Main()
        ' Create a managed array.
        Dim managedArray As Byte() = {1, 2, 3, 4}

        ' Initialize unmanaged memory to hold the array.
        Dim size As Integer = Marshal.SizeOf(managedArray(0)) * managedArray.Length

        Dim pnt As IntPtr = Marshal.AllocHGlobal(size)

        Try
            ' Copy the array to unmanaged memory.
            Marshal.Copy(managedArray, 0, pnt, managedArray.Length)

            ' Copy the unmanaged array back to another managed array.
            Dim managedArray2(managedArray.Length) As Byte

            Marshal.Copy(pnt, managedArray2, 0, managedArray.Length)

            Console.WriteLine("The array was copied to unmanaged memory and back.")

        Finally
            ' Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt)
        End Try

    End Sub
End Module

Comentarios

Puede usar este método para copiar un subconjunto de una matriz administrada unidimensional en una matriz de estilo C no administrada.

Se aplica a