Share via


Marshal.WriteInt64 Méthode

Définition

Écrit une valeur d'entier 64 bits signé dans la mémoire non managée. L'écriture dans la mémoire non alignée est prise en charge.

Surcharges

WriteInt64(Object, Int32, Int64)
Obsolète.

Écrit une valeur entière signée 64 bits dans la mémoire non managée à un offset spécifié.

WriteInt64(IntPtr, Int64)

Écrit une valeur d'entier 64 bits signé dans la mémoire non managée.

WriteInt64(IntPtr, Int32, Int64)

Écrit une valeur entière signée 64 bits dans la mémoire non managée à un offset spécifié.

WriteInt64(Object, Int32, Int64)

Source:
Marshal.CoreCLR.cs
Source:
Marshal.CoreCLR.cs
Source:
Marshal.CoreCLR.cs

Attention

WriteInt64(Object, Int32, Int64) may be unavailable in future releases.

Écrit une valeur entière signée 64 bits dans la mémoire non managée à un offset spécifié.

public:
 static void WriteInt64(System::Object ^ ptr, int ofs, long val);
[System.Obsolete("WriteInt64(Object, Int32, Int64) may be unavailable in future releases.")]
[System.Security.SecurityCritical]
public static void WriteInt64 (object ptr, int ofs, long val);
[System.Obsolete("WriteInt64(Object, Int32, Int64) may be unavailable in future releases.")]
public static void WriteInt64 (object ptr, int ofs, long val);
public static void WriteInt64 (object ptr, int ofs, long val);
[System.Security.SecurityCritical]
public static void WriteInt64 (object ptr, int ofs, long val);
[<System.Obsolete("WriteInt64(Object, Int32, Int64) may be unavailable in future releases.")>]
[<System.Security.SecurityCritical>]
static member WriteInt64 : obj * int * int64 -> unit
[<System.Obsolete("WriteInt64(Object, Int32, Int64) may be unavailable in future releases.")>]
static member WriteInt64 : obj * int * int64 -> unit
static member WriteInt64 : obj * int * int64 -> unit
[<System.Security.SecurityCritical>]
static member WriteInt64 : obj * int * int64 -> unit
Public Shared Sub WriteInt64 (ptr As Object, ofs As Integer, val As Long)

Paramètres

ptr
Object

Adresse de base dans la mémoire non managée de l'objet cible.

ofs
Int32

Offset d'octet supplémentaire, qui est ajouté au paramètre ptr avant l'écriture.

val
Int64

Valeur à écrire.

Attributs

Exceptions

L'adresse de base (ptr) plus l'octet d'offset (ofs) produisent une adresse null ou non valide.

ptr est un objet ArrayWithOffset. Cette méthode n'accepte pas les paramètres ArrayWithOffset.

Remarques

WriteInt64 permet l’interaction directe avec un tableau signé 64 bits non managé, éliminant les frais de copie d’un tableau non managé entier (à l’aide Marshal.Copyde ) dans un tableau managé distinct avant de définir ses valeurs d’élément.

L'écriture dans la mémoire non alignée est prise en charge.

Voir aussi

S’applique à

WriteInt64(IntPtr, Int64)

Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

Écrit une valeur d'entier 64 bits signé dans la mémoire non managée.

public:
 static void WriteInt64(IntPtr ptr, long val);
[System.Security.SecurityCritical]
public static void WriteInt64 (IntPtr ptr, long val);
public static void WriteInt64 (IntPtr ptr, long val);
[<System.Security.SecurityCritical>]
static member WriteInt64 : nativeint * int64 -> unit
static member WriteInt64 : nativeint * int64 -> unit
Public Shared Sub WriteInt64 (ptr As IntPtr, val As Long)

Paramètres

ptr
IntPtr

nativeint

Adresse où écrire dans la mémoire non managée.

val
Int64

Valeur à écrire.

Attributs

Exceptions

ptr n'est pas un format reconnu.

- ou -

ptr a la valeur null.

- ou -

ptr n'est pas valide.

Exemples

L’exemple suivant montre comment lire et écrire dans un tableau non managé à l’aide des ReadInt64 méthodes et WriteInt64 .

static void ReadWriteInt64()
{
    // Allocate unmanaged memory. 
    int elementSize = 8;
    IntPtr unmanagedArray = Marshal.AllocHGlobal(10 * elementSize);

    // Set the 10 elements of the C-style unmanagedArray
    for (int i = 0; i < 10; i++)
    {
        Marshal.WriteInt64(unmanagedArray, i * elementSize, ((Int64)(i + 1)));
    }
    Console.WriteLine("Unmanaged memory written.");

    Console.WriteLine("Reading unmanaged memory:");
    // Print the 10 elements of the C-style unmanagedArray
    for (int i = 0; i < 10; i++)
    {
        Console.WriteLine(Marshal.ReadInt64(unmanagedArray, i * elementSize));
    }

    Marshal.FreeHGlobal(unmanagedArray);

    Console.WriteLine("Done. Press Enter to continue.");
    Console.ReadLine();
}
Sub ReadWriteInt64()
    ' Allocate unmanaged memory. 
    Dim elementSize As Integer = 8
    Dim unmanagedArray As IntPtr = Marshal.AllocHGlobal(10 * elementSize)

    ' Set the 10 elements of the C-style unmanagedArray
    For i As Integer = 0 To 9
        Marshal.WriteInt64(unmanagedArray, i * elementSize, CType(i + 1, Int64))
    Next i
    Console.WriteLine("Unmanaged memory written.")

    Console.WriteLine("Reading unmanaged memory:")
    ' Print the 10 elements of the C-style unmanagedArray
    For i As Integer = 0 To 9
        Console.WriteLine(Marshal.ReadInt64(unmanagedArray, i * elementSize))
    Next i

    Marshal.FreeHGlobal(unmanagedArray)

    Console.WriteLine("Done. Press Enter to continue.")
    Console.ReadLine()
End Sub

Remarques

WriteInt64 permet l’interaction directe avec un tableau signé 64 bits non managé, éliminant les frais de copie d’un tableau non managé entier (à l’aide Marshal.Copyde ) dans un tableau managé distinct avant de définir ses valeurs d’élément.

L'écriture dans la mémoire non alignée est prise en charge.

Voir aussi

S’applique à

WriteInt64(IntPtr, Int32, Int64)

Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

Écrit une valeur entière signée 64 bits dans la mémoire non managée à un offset spécifié.

public:
 static void WriteInt64(IntPtr ptr, int ofs, long val);
[System.Security.SecurityCritical]
public static void WriteInt64 (IntPtr ptr, int ofs, long val);
public static void WriteInt64 (IntPtr ptr, int ofs, long val);
[<System.Security.SecurityCritical>]
static member WriteInt64 : nativeint * int * int64 -> unit
static member WriteInt64 : nativeint * int * int64 -> unit
Public Shared Sub WriteInt64 (ptr As IntPtr, ofs As Integer, val As Long)

Paramètres

ptr
IntPtr

nativeint

Adresse de base de la mémoire non managée à écrire.

ofs
Int32

Offset d'octet supplémentaire, qui est ajouté au paramètre ptr avant l'écriture.

val
Int64

Valeur à écrire.

Attributs

Exceptions

L'adresse de base (ptr) plus l'octet d'offset (ofs) produisent une adresse null ou non valide.

Exemples

L’exemple suivant montre comment lire et écrire dans un tableau non managé à l’aide des ReadInt64 méthodes et WriteInt64 .

static void ReadWriteInt64()
{
    // Allocate unmanaged memory. 
    int elementSize = 8;
    IntPtr unmanagedArray = Marshal.AllocHGlobal(10 * elementSize);

    // Set the 10 elements of the C-style unmanagedArray
    for (int i = 0; i < 10; i++)
    {
        Marshal.WriteInt64(unmanagedArray, i * elementSize, ((Int64)(i + 1)));
    }
    Console.WriteLine("Unmanaged memory written.");

    Console.WriteLine("Reading unmanaged memory:");
    // Print the 10 elements of the C-style unmanagedArray
    for (int i = 0; i < 10; i++)
    {
        Console.WriteLine(Marshal.ReadInt64(unmanagedArray, i * elementSize));
    }

    Marshal.FreeHGlobal(unmanagedArray);

    Console.WriteLine("Done. Press Enter to continue.");
    Console.ReadLine();
}
Sub ReadWriteInt64()
    ' Allocate unmanaged memory. 
    Dim elementSize As Integer = 8
    Dim unmanagedArray As IntPtr = Marshal.AllocHGlobal(10 * elementSize)

    ' Set the 10 elements of the C-style unmanagedArray
    For i As Integer = 0 To 9
        Marshal.WriteInt64(unmanagedArray, i * elementSize, CType(i + 1, Int64))
    Next i
    Console.WriteLine("Unmanaged memory written.")

    Console.WriteLine("Reading unmanaged memory:")
    ' Print the 10 elements of the C-style unmanagedArray
    For i As Integer = 0 To 9
        Console.WriteLine(Marshal.ReadInt64(unmanagedArray, i * elementSize))
    Next i

    Marshal.FreeHGlobal(unmanagedArray)

    Console.WriteLine("Done. Press Enter to continue.")
    Console.ReadLine()
End Sub

Remarques

WriteInt64 permet l’interaction directe avec un tableau signé 64 bits non managé, éliminant les frais de copie d’un tableau non managé entier (à l’aide Marshal.Copyde ) dans un tableau managé distinct avant de définir ses valeurs d’élément.

L'écriture dans la mémoire non alignée est prise en charge.

Voir aussi

S’applique à