1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-10 05:55:41 +00:00

(#39) Use inline ternary instead of cast

This commit is contained in:
Oliver Booth 2021-03-12 12:03:30 +00:00
parent ef78f86b3a
commit 5dab9323b6

View File

@ -62,7 +62,7 @@ namespace X10D.BooleanExtensions
/// </example> /// </example>
public static decimal ToDecimal(this bool value) public static decimal ToDecimal(this bool value)
{ {
return value.ToByte(); return value ? 1.0m : 0.0m;
} }
/// <summary> /// <summary>
@ -86,7 +86,7 @@ namespace X10D.BooleanExtensions
/// </example> /// </example>
public static double ToDouble(this bool value) public static double ToDouble(this bool value)
{ {
return value.ToByte(); return value ? 1.0 : 0.0;
} }
/// <summary> /// <summary>
@ -112,7 +112,7 @@ namespace X10D.BooleanExtensions
/// </example> /// </example>
public static short ToInt16(this bool value) public static short ToInt16(this bool value)
{ {
return value.ToByte(); return value ? 1 : 0;
} }
/// <summary> /// <summary>
@ -138,7 +138,7 @@ namespace X10D.BooleanExtensions
/// </example> /// </example>
public static int ToInt32(this bool value) public static int ToInt32(this bool value)
{ {
return value.ToByte(); return value ? 1 : 0;
} }
/// <summary> /// <summary>
@ -164,7 +164,7 @@ namespace X10D.BooleanExtensions
/// </example> /// </example>
public static long ToInt64(this bool value) public static long ToInt64(this bool value)
{ {
return value.ToByte(); return value ? 1L : 0L;
} }
/// <summary> /// <summary>
@ -190,7 +190,7 @@ namespace X10D.BooleanExtensions
/// </example> /// </example>
public static float ToSingle(this bool value) public static float ToSingle(this bool value)
{ {
return value.ToByte(); return value ? 1.0f : 0.0f;
} }
} }
} }