mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 01:28:48 +00:00
(#39) Use inline ternary instead of cast
This commit is contained in:
parent
ef78f86b3a
commit
5dab9323b6
@ -62,7 +62,7 @@ namespace X10D.BooleanExtensions
|
||||
/// </example>
|
||||
public static decimal ToDecimal(this bool value)
|
||||
{
|
||||
return value.ToByte();
|
||||
return value ? 1.0m : 0.0m;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -86,7 +86,7 @@ namespace X10D.BooleanExtensions
|
||||
/// </example>
|
||||
public static double ToDouble(this bool value)
|
||||
{
|
||||
return value.ToByte();
|
||||
return value ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,7 +112,7 @@ namespace X10D.BooleanExtensions
|
||||
/// </example>
|
||||
public static short ToInt16(this bool value)
|
||||
{
|
||||
return value.ToByte();
|
||||
return value ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -138,7 +138,7 @@ namespace X10D.BooleanExtensions
|
||||
/// </example>
|
||||
public static int ToInt32(this bool value)
|
||||
{
|
||||
return value.ToByte();
|
||||
return value ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -164,7 +164,7 @@ namespace X10D.BooleanExtensions
|
||||
/// </example>
|
||||
public static long ToInt64(this bool value)
|
||||
{
|
||||
return value.ToByte();
|
||||
return value ? 1L : 0L;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -190,7 +190,7 @@ namespace X10D.BooleanExtensions
|
||||
/// </example>
|
||||
public static float ToSingle(this bool value)
|
||||
{
|
||||
return value.ToByte();
|
||||
return value ? 1.0f : 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user