Marshal.WriteInt64 메서드
정의
관리되지 않는 메모리에 부호 있는 64비트 정수 값을 씁니다.Writes a 64-bit signed integer value to unmanaged memory. 정렬되지 않은 메모리 위치에 쓸 수 있습니다.Writing to unaligned memory locations is supported.
오버로드
WriteInt64(Object, Int32, Int64) |
사용되지 않습니다.
관리되지 않는 메모리의 지정된 오프셋 위치에 64비트 부호 있는 정수 값을 씁니다.Writes a 64-bit signed integer value to unmanaged memory at a specified offset. |
WriteInt64(IntPtr, Int64) |
관리되지 않는 메모리에 부호 있는 64비트 정수 값을 씁니다.Writes a 64-bit signed integer value to unmanaged memory. |
WriteInt64(IntPtr, Int32, Int64) |
관리되지 않는 메모리의 지정된 오프셋 위치에 64비트 부호 있는 정수 값을 씁니다.Writes a 64-bit signed integer value to unmanaged memory at a specified offset. |
WriteInt64(Object, Int32, Int64)
주의
WriteInt64(Object, Int32, Int64) may be unavailable in future releases.
관리되지 않는 메모리의 지정된 오프셋 위치에 64비트 부호 있는 정수 값을 씁니다.Writes a 64-bit signed integer value to unmanaged memory at a specified offset.
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)
매개 변수
- ptr
- Object
대상 개체에 대한 관리되지 않는 메모리의 기본 주소입니다.The base address in unmanaged memory of the target object.
- ofs
- Int32
쓰기 전에 ptr
매개 변수에 추가되는 추가 바이트 오프셋입니다.An additional byte offset, which is added to the ptr
parameter before writing.
- val
- Int64
작성할 값입니다.The value to write.
- 특성
예외
기준 주소(ptr
)에 오프셋 바이트(ofs
)를 더하면 null 또는 잘못된 주소가 생성되는 경우Base address (ptr
) plus offset byte (ofs
) produces a null or invalid address.
ptr
이 ArrayWithOffset 개체인 경우.ptr
is an ArrayWithOffset object. 이 메서드에는 ArrayWithOffset 매개 변수를 사용할 수 없습니다.This method does not accept ArrayWithOffset parameters.
설명
WriteInt64 관리 되지 않는 64 비트 부호 있는 배열과의 직접 상호 작용을 사용 하 여 해당 요소 값을 설정 하기 전에 관리 되지 않는 전체 배열 (사용 Marshal.Copy )을 별도의 관리 되는 배열에 복사 하는 비용을 제거 합니다.WriteInt64 enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using Marshal.Copy) to a separate managed array before setting its element values.
정렬되지 않은 메모리 위치에 쓸 수 있습니다.Writing to unaligned memory locations is supported.
추가 정보
적용 대상
WriteInt64(IntPtr, Int64)
관리되지 않는 메모리에 부호 있는 64비트 정수 값을 씁니다.Writes a 64-bit signed integer value to unmanaged memory.
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)
매개 변수
- ptr
- IntPtr
관리되지 않는 메모리에서 값을 쓸 주소입니다.The address in unmanaged memory to write to.
- val
- Int64
작성할 값입니다.The value to write.
- 특성
예외
ptr
의 형식을 인식할 수 없는 경우ptr
is not a recognized format.
또는-or-
ptr
은 null
입니다.ptr
is null
.
또는-or-
ptr
이 잘못되었습니다.ptr
is invalid.
예제
다음 예제에서는 및 메서드를 사용 하 여 관리 되지 않는 배열을 읽고 쓰는 방법을 보여 줍니다 ReadInt64 WriteInt64 .The following example demonstrates how to read and write to an unmanaged array using the ReadInt64 and WriteInt64 methods.
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
설명
WriteInt64 관리 되지 않는 64 비트 부호 있는 배열과의 직접 상호 작용을 사용 하 여 해당 요소 값을 설정 하기 전에 관리 되지 않는 전체 배열 (사용 Marshal.Copy )을 별도의 관리 되는 배열에 복사 하는 비용을 제거 합니다.WriteInt64 enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using Marshal.Copy) to a separate managed array before setting its element values.
정렬되지 않은 메모리 위치에 쓸 수 있습니다.Writing to unaligned memory locations is supported.
추가 정보
적용 대상
WriteInt64(IntPtr, Int32, Int64)
관리되지 않는 메모리의 지정된 오프셋 위치에 64비트 부호 있는 정수 값을 씁니다.Writes a 64-bit signed integer value to unmanaged memory at a specified offset.
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)
매개 변수
- ptr
- IntPtr
데이터를 쓸 관리되지 않는 메모리의 기본 주소입니다.The base address in unmanaged memory to write.
- ofs
- Int32
쓰기 전에 ptr
매개 변수에 추가되는 추가 바이트 오프셋입니다.An additional byte offset, which is added to the ptr
parameter before writing.
- val
- Int64
작성할 값입니다.The value to write.
- 특성
예외
기준 주소(ptr
)에 오프셋 바이트(ofs
)를 더하면 null 또는 잘못된 주소가 생성되는 경우Base address (ptr
) plus offset byte (ofs
) produces a null or invalid address.
예제
다음 예제에서는 및 메서드를 사용 하 여 관리 되지 않는 배열을 읽고 쓰는 방법을 보여 줍니다 ReadInt64 WriteInt64 .The following example demonstrates how to read and write to an unmanaged array using the ReadInt64 and WriteInt64 methods.
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
설명
WriteInt64 관리 되지 않는 64 비트 부호 있는 배열과의 직접 상호 작용을 사용 하 여 해당 요소 값을 설정 하기 전에 관리 되지 않는 전체 배열 (사용 Marshal.Copy )을 별도의 관리 되는 배열에 복사 하는 비용을 제거 합니다.WriteInt64 enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using Marshal.Copy) to a separate managed array before setting its element values.
정렬되지 않은 메모리 위치에 쓸 수 있습니다.Writing to unaligned memory locations is supported.