Marshal.WriteInt64 Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Escreve um valor inteiro assinado de 64 bits na memória não gerida. A escrita em locais de memória desalinhados é suportada.
Sobrecargas
| Name | Description |
|---|---|
| WriteInt64(Object, Int32, Int64) |
Obsoleto.
Escreve um valor inteiro assinado de 64 bits em memória não gerida a um deslocamento especificado. |
| WriteInt64(IntPtr, Int64) |
Escreve um valor inteiro assinado de 64 bits na memória não gerida. |
| WriteInt64(IntPtr, Int32, Int64) |
Escreve um valor inteiro assinado de 64 bits em memória não gerida a um deslocamento especificado. |
WriteInt64(Object, Int32, Int64)
Atenção
WriteInt64(Object, Int32, Int64) may be unavailable in future releases.
Escreve um valor inteiro assinado de 64 bits em memória não gerida a um deslocamento especificado.
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);
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.")]
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
static member WriteInt64 : obj * int * int64 -> unit
[<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
Public Shared Sub WriteInt64 (ptr As Object, ofs As Integer, val As Long)
Parâmetros
- ptr
- Object
O endereço base na memória não gerida do objeto alvo.
- ofs
- Int32
Um deslocamento adicional de byte, que é adicionado ao ptr parâmetro antes da escrita.
- val
- Int64
O valor a escrever.
- Atributos
Exceções
O endereço base (ptr) mais o byte offset (ofs) produz um endereço nulo ou inválido.
ptr é um ArrayWithOffset objeto. Este método não aceita ArrayWithOffset parâmetros.
Observações
WriteInt64 permite a interação direta com um array de assinatura não gerido de 64 bits, eliminando o custo de copiar um array inteiro não gerido (usando Marshal.Copy) para um array gerido separado antes de definir os valores dos seus elementos.
A escrita em locais de memória desalinhados é suportada.
Ver também
Aplica-se a
WriteInt64(IntPtr, Int64)
Escreve um valor inteiro assinado de 64 bits na memória não gerida.
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)
Parâmetros
- ptr
-
IntPtr
nativeint
O endereço na memória não gerida para escrever.
- val
- Int64
O valor a escrever.
- Atributos
Exceções
Exemplos
O exemplo seguinte demonstra como ler e escrever num array não gerido usando os ReadInt64 métodos 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
Observações
WriteInt64 permite a interação direta com um array de assinatura não gerido de 64 bits, eliminando o custo de copiar um array inteiro não gerido (usando Marshal.Copy) para um array gerido separado antes de definir os valores dos seus elementos.
A escrita em locais de memória desalinhados é suportada.
Ver também
Aplica-se a
WriteInt64(IntPtr, Int32, Int64)
Escreve um valor inteiro assinado de 64 bits em memória não gerida a um deslocamento especificado.
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)
Parâmetros
- ptr
-
IntPtr
nativeint
O endereço base na memória não gerida para escrever.
- ofs
- Int32
Um deslocamento adicional de byte, que é adicionado ao ptr parâmetro antes da escrita.
- val
- Int64
O valor a escrever.
- Atributos
Exceções
O endereço base (ptr) mais o byte offset (ofs) produz um endereço nulo ou inválido.
Exemplos
O exemplo seguinte demonstra como ler e escrever num array não gerido usando os ReadInt64 métodos 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
Observações
WriteInt64 permite a interação direta com um array de assinatura não gerido de 64 bits, eliminando o custo de copiar um array inteiro não gerido (usando Marshal.Copy) para um array gerido separado antes de definir os valores dos seus elementos.
A escrita em locais de memória desalinhados é suportada.