From 66d68b01bfa21a68694ac0569657c375a48d74d8 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 18 Apr 2020 23:38:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20ToInt16=20and=20ToInt64=20in?= =?UTF-8?q?=20BooleanExtensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- X10D/src/BooleanExtensions.cs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/X10D/src/BooleanExtensions.cs b/X10D/src/BooleanExtensions.cs index 4c5f9e1..b16ba83 100644 --- a/X10D/src/BooleanExtensions.cs +++ b/X10D/src/BooleanExtensions.cs @@ -65,23 +65,43 @@ } /// - /// Gets an integer value that represents this boolean. + /// Gets the value of this boolean as represented by . /// /// The boolean. - /// Returns 1 if is , 0 otherwise. + /// Returns 1 if is , or 0 otherwise. + public static byte ToByte(this bool value) + { + return (byte)value.ToInt32(); + } + + /// + /// Gets the value of this boolean as represented by . + /// + /// The boolean. + /// Returns 1 if is , or 0 otherwise. + public static short ToInt16(this bool value) + { + return (short)value.ToInt32(); + } + + /// + /// Gets the value of this boolean as represented by . + /// + /// The boolean. + /// Returns 1 if is , or 0 otherwise. public static int ToInt32(this bool value) { return value ? 1 : 0; } /// - /// Gets a byte value that represents this boolean. + /// Gets the value of this boolean as represented by . /// /// The boolean. - /// Returns 00000001 if is , otherwise 0000000. - public static byte ToByte(this bool value) + /// Returns 1 if is , 0 otherwise. + public static long ToInt64(this bool value) { - return (byte)(value ? 1 : 0); + return value.ToInt32(); } ///