mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:05:42 +00:00
✨ Add ToInt16 and ToInt64 in BooleanExtensions
This commit is contained in:
parent
6be765a92d
commit
66d68b01bf
@ -65,23 +65,43 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an integer value that represents this boolean.
|
/// Gets the value of this boolean as represented by <see cref="byte"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The boolean.</param>
|
/// <param name="value">The boolean.</param>
|
||||||
/// <returns>Returns 1 if <paramref name="value"/> is <see langword="true"/>, 0 otherwise.</returns>
|
/// <returns>Returns 1 if <paramref name="value"/> is <see langword="true"/>, or 0 otherwise.</returns>
|
||||||
|
public static byte ToByte(this bool value)
|
||||||
|
{
|
||||||
|
return (byte)value.ToInt32();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value of this boolean as represented by <see cref="short"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The boolean.</param>
|
||||||
|
/// <returns>Returns 1 if <paramref name="value"/> is <see langword="true"/>, or 0 otherwise.</returns>
|
||||||
|
public static short ToInt16(this bool value)
|
||||||
|
{
|
||||||
|
return (short)value.ToInt32();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value of this boolean as represented by <see cref="int"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The boolean.</param>
|
||||||
|
/// <returns>Returns 1 if <paramref name="value"/> is <see langword="true"/>, or 0 otherwise.</returns>
|
||||||
public static int ToInt32(this bool value)
|
public static int ToInt32(this bool value)
|
||||||
{
|
{
|
||||||
return value ? 1 : 0;
|
return value ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a byte value that represents this boolean.
|
/// Gets the value of this boolean as represented by <see cref="long"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The boolean.</param>
|
/// <param name="value">The boolean.</param>
|
||||||
/// <returns>Returns 00000001 if <paramref name="value"/> is <see langword="true"/>, otherwise 0000000.</returns>
|
/// <returns>Returns 1 if <paramref name="value"/> is <see langword="true"/>, 0 otherwise.</returns>
|
||||||
public static byte ToByte(this bool value)
|
public static long ToInt64(this bool value)
|
||||||
{
|
{
|
||||||
return (byte)(value ? 1 : 0);
|
return value.ToInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user