From cb40ecb22c2afe2efb8617dec2041cccd6d63306 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 12 Mar 2021 13:19:52 +0000 Subject: [PATCH] (#15) Add usage example for bool.GetBytes --- .../BooleanExtensions/BooleanExtensions.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.cs b/X10D/src/BooleanExtensions/BooleanExtensions.cs index 0980109..ca8c8f9 100644 --- a/X10D/src/BooleanExtensions/BooleanExtensions.cs +++ b/X10D/src/BooleanExtensions/BooleanExtensions.cs @@ -12,6 +12,26 @@ namespace X10D.BooleanExtensions /// /// The Boolean value. /// A byte array with length 1. + /// + /// The following example converts the bit patterns of values to arrays. + /// + /// + /// 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 + /// + /// public static byte[] GetBytes(this bool value) { return BitConverter.GetBytes(value);