System.Guid.ToByteArray Method

Returns a 16-element byte array that contains the value of this instance.

Syntax

public byte[] ToByteArray ()

Returns

A 16-element byte array.

Remarks

You can use the byte array returned by this method to round-trip a Guid value by calling the Guid.#ctor(Byte[]) constructor.

Note that the order of bytes in the returned byte array is different from the string representation of a Guid value. The order of the beginning four-byte group and the next two two-byte groups is reversed, whereas the order of the last two-byte group and the closing six-byte group is the same. The example provides an illustration.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0