CryptographicBuffer.CopyToByteArray(IBuffer, Byte[]) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Copies a buffer to an array of bytes.
static void CopyToByteArray(IBuffer const& buffer, [Out] winrt::array_view <byte> const& & value);
public static void CopyToByteArray(IBuffer buffer, out byte[] value);
Public Shared Sub CopyToByteArray (buffer As IBuffer, ByRef value As Byte())
Parameters
- buffer
- IBuffer
Input buffer.
- value
-
Byte[]
byte[]
An array of bytes that contains the values copied from the input buffer. You must declare the array before calling this method and pass it by using the ref keyword. If the buffer for the input parameter is empty, then the value parameter will be returned as NULL.
Examples
public void ByteArrayCopy()
{
// Initialize a byte array.
byte[] arrByte = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
// Create a buffer from the byte array.
IBuffer buffer = CryptographicBuffer.CreateFromByteArray(arrByte);
// Encode the buffer into a hexadecimal string (for display);
String strHex = CryptographicBuffer.EncodeToHexString(buffer);
// Copy the buffer back into a new byte array.
byte[] arrByteNew;
CryptographicBuffer.CopyToByteArray(buffer, out arrByteNew);
}
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for