Condividi tramite


CryptographicBuffer.CopyToByteArray(IBuffer, Byte[]) Metodo

Definizione

Copia un buffer in una matrice di byte.

 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())

Parametri

buffer
IBuffer

Buffer di input.

value

Byte[]

byte[]

Matrice di byte che contiene i valori copiati dal buffer di input. È necessario dichiarare la matrice prima di chiamare questo metodo e passarla usando la parola chiave ref . Se il buffer per il parametro di input è vuoto, il parametro value verrà restituito come NULL.

Esempio

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);
}

Si applica a