This documentation is archived and is not being maintained.

Marshal.Copy Method (Single[], Int32, IntPtr, Int32)

.NET Framework 1.1

Copies data from a one-dimensional, managed single-precision floating-point number array to an unmanaged memory pointer.

[Visual Basic]
Overloads Public Shared Sub Copy( _
   ByVal source() As Single, _
   ByVal startIndex As Integer, _
   ByVal destination As IntPtr, _
   ByVal length As Integer _
public static void Copy(
 float[] source,
 int startIndex,
 IntPtr destination,
 int length
public: static void Copy(
 float source __gc[],
 int startIndex,
 IntPtr destination,
 int length
public static function Copy(
   source : float[],
 startIndex : int,
 destination : IntPtr,
 length : int


The one-dimensional array to copy from.
The zero-based index into the array where Copy should start.
The memory pointer to copy to.
The number of array elements to copy.


Exception Type Condition
ArgumentOutOfRangeException startIndex and length are not valid.


You can use this method to copy a subset of a one-dimensional, .NET-based array to an unmanaged C-style array.

Note   This method uses SecurityAction.LinkDemand to prevent it from being called from untrusted code; only the immediate caller is required to have SecurityPermissionAttribute.UnmanagedCode permission. If your code can be called from partially trusted code, do not pass user input to Marshal class methods without validation. For important limitations on using the LinkDemand member, see Demand vs. LinkDemand.


[Visual Basic, C#] The following example demonstrates how to copy a one-dimensional array to an unmanaged memory pointer.

[Visual Basic] 
Public Overloads Shared Sub Copy(source As Single(), _
  startIndex As Integer, destination As IntPtr, length As Integer)
public static void Copy(float[] source, int startIndex, 
  IntPtr destination, int length);

[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.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

.NET Framework Security: 

See Also

Marshal Class | Marshal Members | System.Runtime.InteropServices Namespace | Marshal.Copy Overload List