Marshal.WriteInt64 Metodo

Definizione

Scrive un valore intero con segno a 64 bit nella memoria non gestita. La scrittura in percorsi di memoria non allineati è supportata.

Overload

Nome Descrizione
WriteInt64(Object, Int32, Int64)
Obsoleti.

Scrive un valore intero con segno a 64 bit nella memoria non gestita in corrispondenza di un offset specificato.

WriteInt64(IntPtr, Int64)

Scrive un valore intero con segno a 64 bit nella memoria non gestita.

WriteInt64(IntPtr, Int32, Int64)

Scrive un valore intero con segno a 64 bit nella memoria non gestita in corrispondenza di un offset specificato.

WriteInt64(Object, Int32, Int64)

Origine:
Marshal.CoreCLR.cs
Origine:
Marshal.CoreCLR.cs
Origine:
Marshal.CoreCLR.cs
Origine:
Marshal.CoreCLR.cs
Origine:
Marshal.CoreCLR.cs

Attenzione

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

Scrive un valore intero con segno a 64 bit nella memoria non gestita in corrispondenza di un offset specificato.

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.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the object might not be available")]
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.")>]
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the object might not be available")>]
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)

Parametri

ptr
Object

Indirizzo di base nella memoria non gestita dell'oggetto di destinazione.

ofs
Int32

Offset di byte aggiuntivo, che viene aggiunto al parametro prima della ptr scrittura.

val
Int64

Valore da scrivere.

Attributi

Eccezioni

L'indirizzo di base (ptr) più byte offset (ofs) produce un indirizzo Null o non valido.

ptr è un ArrayWithOffset oggetto . Questo metodo non accetta ArrayWithOffset parametri.

Commenti

WriteInt64 consente l'interazione diretta con una matrice con segno a 64 bit non gestita, eliminando i costi di copia di un'intera matrice non gestita (usando Marshal.Copy) in una matrice gestita separata prima di impostarne i valori degli elementi.

La scrittura in percorsi di memoria non allineati è supportata.

Vedi anche

Si applica a

WriteInt64(IntPtr, Int64)

Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs

Scrive un valore intero con segno a 64 bit nella memoria non gestita.

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)

Parametri

ptr
IntPtr

nativeint

Indirizzo in memoria non gestita in cui scrivere.

val
Int64

Valore da scrivere.

Attributi

Eccezioni

ptr non è un formato riconosciuto.

oppure

ptr è null.

oppure

ptr non è valido.

Esempio

Nell'esempio seguente viene illustrato come leggere e scrivere in una matrice non gestita usando i ReadInt64 metodi e 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

Commenti

WriteInt64 consente l'interazione diretta con una matrice con segno a 64 bit non gestita, eliminando i costi di copia di un'intera matrice non gestita (usando Marshal.Copy) in una matrice gestita separata prima di impostarne i valori degli elementi.

La scrittura in percorsi di memoria non allineati è supportata.

Vedi anche

Si applica a

WriteInt64(IntPtr, Int32, Int64)

Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs

Scrive un valore intero con segno a 64 bit nella memoria non gestita in corrispondenza di un offset specificato.

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)

Parametri

ptr
IntPtr

nativeint

Indirizzo di base nella memoria non gestita da scrivere.

ofs
Int32

Offset di byte aggiuntivo, che viene aggiunto al parametro prima della ptr scrittura.

val
Int64

Valore da scrivere.

Attributi

Eccezioni

L'indirizzo di base (ptr) più byte offset (ofs) produce un indirizzo Null o non valido.

Esempio

Nell'esempio seguente viene illustrato come leggere e scrivere in una matrice non gestita usando i ReadInt64 metodi e 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

Commenti

WriteInt64 consente l'interazione diretta con una matrice con segno a 64 bit non gestita, eliminando i costi di copia di un'intera matrice non gestita (usando Marshal.Copy) in una matrice gestita separata prima di impostarne i valori degli elementi.

La scrittura in percorsi di memoria non allineati è supportata.

Vedi anche

Si applica a