mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:25:41 +00:00
(#15) Add usage example for bool.GetBytes
This commit is contained in:
parent
84706fe54b
commit
cb40ecb22c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user