This documentation is archived and is not being maintained.

Marshal.WriteInt64 Method

Writes a 64-bit signed integer value to unmanaged memory.

Overload List

Writes a 64-bit signed integer value to unmanaged memory.

[Visual Basic] Overloads Public Shared Sub WriteInt64(IntPtr, Long)
[C#] public static void WriteInt64(IntPtr, long);
[C++] public: static void WriteInt64(IntPtr, __int64);
[JScript] public static function WriteInt64(IntPtr, long);

Writes a 64-bit signed integer value to unmanaged memory.

[Visual Basic] Overloads Public Shared Sub WriteInt64(IntPtr, Integer, Long)
[C#] public static void WriteInt64(IntPtr, int, long);
[C++] public: static void WriteInt64(IntPtr, int, __int64);
[JScript] public static function WriteInt64(IntPtr, int, long);

Writes a 64-bit signed integer value to unmanaged memory.

[Visual Basic] Overloads Public Shared Sub WriteInt64(Object, Integer, Long)
[C#] public static void WriteInt64(object, int, long);
[C++] public: static void WriteInt64(Object, int, __int64);
[JScript] public static function WriteInt64(Object, int, long);

Example

[Visual Basic, C#] The following example compares two ways of interacting with an unmanaged C-style Int64 array. The WriteInt64 method provides direct access to the element values of the array, setting its ten elements to the values 1 through 10.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of WriteInt64. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Dim unmanagedArray As IntPtr = ...
Dim i As Integer
' One way to set the 10 elements of the C-style unmanagedArray
Dim newArray As Long(9)
Marshal.Copy(unmanagedArray, newArray, 0, 10)
For i = 0 To newArray.Length
  newArray(i) = i+1
Next i
Marshal.Copy(newArray, 0, unmanagedArray, 10)
' Another way to set the 10 elements of the C-style unmanagedArray
For i = 0 To 10
  Marshal.WriteInt64(unmanagedArray, i, i+1)
Next i
   
[C#] 
IntPtr unmanagedArray = ...;
// One way to set the 10 elements of the C-style unmanagedArray
byte [] newArray = new long[10];
Marshal.Copy(unmanagedArray, newArray, 0, 10);
for (int i = 0; i < newArray.Length; i++)
  newArray[i] = i+1;
Marshal.Copy(newArray, 0, unmanagedArray, 10);
// Another way to set the 10 elements of the C-style unmanagedArray
for (int i = 0; i < 10; i++)
  Marshal.WriteInt64(unmanagedArray, i, i+1);
   

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Marshal Class | Marshal Members | System.Runtime.InteropServices Namespace

Show: