1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:58:48 +00:00

(#15) Add usage example for bool.GetBytes

This commit is contained in:
Oliver Booth 2021-03-12 13:19:52 +00:00
parent 84706fe54b
commit cb40ecb22c

View File

@ -12,6 +12,26 @@ namespace X10D.BooleanExtensions
/// </summary>
/// <param name="value">The Boolean value.</param>
/// <returns>A byte array with length 1.</returns>
/// <example>
/// The following example converts the bit patterns of <see cref="bool" /> values to <see cref="byte" /> arrays.
///
/// <code lang="csharp">
/// bool[] values = { true, false };
///
/// Console.WriteLine("{0,10}{1,16}\n", "Boolean", "Bytes");
/// foreach (var value in values)
/// {
/// byte[] bytes = value.GetBytes();
/// Console.WriteLine("{0,10}{1,16}", value, bytes.AsString());
/// }
///
/// // The example displays the following output:
/// // Boolean Bytes
/// //
/// // True 01
/// // False 00
/// </code>
/// </example>
public static byte[] GetBytes(this bool value)
{
return BitConverter.GetBytes(value);