Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 851 Bytes

how-to-obtain-a-pointer-to-byte-array.md

File metadata and controls

30 lines (24 loc) · 851 Bytes
descriptiontitlems.customms.datehelpviewer_keywordsms.assetid
Learn more about: How to: Obtain a Pointer to Byte Array
How to: Obtain a Pointer to Byte Array
get-started-article
11/04/2016
pointers, to Byte array
Byte arrays
aea18073-3341-47f4-9f0e-04e03327037e

How to: Obtain a Pointer to Byte Array

You can obtain a pointer to the array block in a xref:System.Byte array by taking the address of the first element and assigning it to a pointer.

Example

// pointer_to_Byte_array.cpp// compile with: /clrusingnamespaceSystem;intmain() { Byte bArr[] = {1, 2, 3}; Byte* pbArr = &bArr[0]; array<Byte> ^ bArr2 = gcnew array<Byte>{1,2,3}; interior_ptr<Byte> pbArr2 = &bArr2[0]; }

See also

Using C++ Interop (Implicit PInvoke)

close