mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:25:41 +00:00
parent
cb40ecb22c
commit
4571697589
@ -8,26 +8,22 @@ namespace X10D.BooleanExtensions
|
|||||||
/// Converts the current Boolean value to the equivalent 8-bit signed integer.
|
/// Converts the current Boolean value to the equivalent 8-bit signed integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The Boolean value to convert.</param>
|
/// <param name="value">The Boolean value to convert.</param>
|
||||||
/// <returns>
|
/// <returns>1 if <paramref name="value" /> is <see langword="false" />, or 0 otherwise.</returns>
|
||||||
/// <c>1</c> if <paramref name="value" /> is <see langword="false" />
|
|
||||||
/// -or-
|
|
||||||
/// <c>0</c> otherwise.
|
|
||||||
/// </returns>
|
|
||||||
/// <example>
|
/// <example>
|
||||||
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="sbyte" /> values.
|
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="sbyte" /> values.
|
||||||
|
///
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// bool falseFlag = false;
|
/// bool falseFlag = false;
|
||||||
/// bool trueFlag = true;
|
/// bool trueFlag = true;
|
||||||
///
|
///
|
||||||
/// Console.WriteLine("{0} converts to {1}.", falseFlag,
|
/// Console.WriteLine("{0} converts to {1}.", falseFlag, falseFlag.ToSByte());
|
||||||
/// falseFlag.ToSByte());
|
/// Console.WriteLine("{0} converts to {1}.", trueFlag, trueFlag.ToSByte());
|
||||||
/// Console.WriteLine("{0} converts to {1}.", trueFlag,
|
|
||||||
/// trueFlag.ToSByte());
|
|
||||||
/// // The example displays the following output:
|
/// // The example displays the following output:
|
||||||
/// // False converts to 0.
|
/// // False converts to 0.
|
||||||
/// // True converts to 1.
|
/// // True converts to 1.
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
|
/// <seealso cref="ByteExtensions.SByteExtensions.ToBoolean(sbyte)" />
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public static sbyte ToSByte(this bool value)
|
public static sbyte ToSByte(this bool value)
|
||||||
{
|
{
|
||||||
@ -38,90 +34,78 @@ namespace X10D.BooleanExtensions
|
|||||||
/// Converts the current Boolean value to the equivalent 16-bit unsigned integer.
|
/// Converts the current Boolean value to the equivalent 16-bit unsigned integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The Boolean value to convert.</param>
|
/// <param name="value">The Boolean value to convert.</param>
|
||||||
/// <returns>
|
/// <returns>1 if <paramref name="value" /> is <see langword="false" />, or 0 otherwise.</returns>
|
||||||
/// <c>1</c> if <paramref name="value" /> is <see langword="false" />
|
|
||||||
/// -or-
|
|
||||||
/// <c>0</c> otherwise.
|
|
||||||
/// </returns>
|
|
||||||
/// <example>
|
/// <example>
|
||||||
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="ushort" /> values.
|
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="ushort" /> values.
|
||||||
|
///
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// bool falseFlag = false;
|
/// bool falseFlag = false;
|
||||||
/// bool trueFlag = true;
|
/// bool trueFlag = true;
|
||||||
///
|
///
|
||||||
/// Console.WriteLine("{0} converts to {1}.", falseFlag,
|
/// Console.WriteLine("{0} converts to {1}.", falseFlag, falseFlag.ToUInt16());
|
||||||
/// falseFlag.ToUInt16());
|
/// Console.WriteLine("{0} converts to {1}.", trueFlag, trueFlag.ToUInt16());
|
||||||
/// Console.WriteLine("{0} converts to {1}.", trueFlag,
|
|
||||||
/// trueFlag.ToUInt16());
|
|
||||||
/// // The example displays the following output:
|
/// // The example displays the following output:
|
||||||
/// // False converts to 0.
|
/// // False converts to 0.
|
||||||
/// // True converts to 1.
|
/// // True converts to 1.
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
|
/// <seealso cref="UInt16Extensions.UInt16Extensions.ToBoolean(ushort)" />
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public static ushort ToUInt16(this bool value)
|
public static ushort ToUInt16(this bool value)
|
||||||
{
|
{
|
||||||
return value.ToByte();
|
return value ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the current Boolean value to the equivalent 32-bit unsigned integer.
|
/// Converts the current Boolean value to the equivalent 32-bit unsigned integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The Boolean value to convert.</param>
|
/// <param name="value">The Boolean value to convert.</param>
|
||||||
/// <returns>
|
/// <returns>1 if <paramref name="value" /> is <see langword="false" />, or 0 otherwise.</returns>
|
||||||
/// <c>1</c> if <paramref name="value" /> is <see langword="false" />
|
|
||||||
/// -or-
|
|
||||||
/// <c>0</c> otherwise.
|
|
||||||
/// </returns>
|
|
||||||
/// <example>
|
/// <example>
|
||||||
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="uint" /> values.
|
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="uint" /> values.
|
||||||
|
///
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// bool falseFlag = false;
|
/// bool falseFlag = false;
|
||||||
/// bool trueFlag = true;
|
/// bool trueFlag = true;
|
||||||
///
|
///
|
||||||
/// Console.WriteLine("{0} converts to {1}.", falseFlag,
|
/// Console.WriteLine("{0} converts to {1}.", falseFlag, falseFlag.ToUInt32());
|
||||||
/// falseFlag.ToUInt32());
|
/// Console.WriteLine("{0} converts to {1}.", trueFlag, trueFlag.ToUInt32());
|
||||||
/// Console.WriteLine("{0} converts to {1}.", trueFlag,
|
|
||||||
/// trueFlag.ToUInt32());
|
|
||||||
/// // The example displays the following output:
|
/// // The example displays the following output:
|
||||||
/// // False converts to 0.
|
/// // False converts to 0.
|
||||||
/// // True converts to 1.
|
/// // True converts to 1.
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
|
/// <seealso cref="UInt32Extensions.UInt32Extensions.ToBoolean(uint)" />
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public static uint ToUInt32(this bool value)
|
public static uint ToUInt32(this bool value)
|
||||||
{
|
{
|
||||||
return value.ToByte();
|
return value ? 1U : 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the current Boolean value to the equivalent 64-bit unsigned integer.
|
/// Converts the current Boolean value to the equivalent 64-bit unsigned integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The Boolean value to convert.</param>
|
/// <param name="value">The Boolean value to convert.</param>
|
||||||
/// <returns>
|
/// <returns>1 if <paramref name="value" /> is <see langword="false" />, or 0 otherwise.</returns>
|
||||||
/// <c>1</c> if <paramref name="value" /> is <see langword="false" />
|
|
||||||
/// -or-
|
|
||||||
/// <c>0</c> otherwise.
|
|
||||||
/// </returns>
|
|
||||||
/// <example>
|
/// <example>
|
||||||
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="ulong" /> values.
|
/// The following example illustrates the conversion of <see cref="bool" /> to <see cref="ulong" /> values.
|
||||||
|
///
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// bool falseFlag = false;
|
/// bool falseFlag = false;
|
||||||
/// bool trueFlag = true;
|
/// bool trueFlag = true;
|
||||||
///
|
///
|
||||||
/// Console.WriteLine("{0} converts to {1}.", falseFlag,
|
/// Console.WriteLine("{0} converts to {1}.", falseFlag, falseFlag.ToUInt64());
|
||||||
/// falseFlag.ToUInt64());
|
/// Console.WriteLine("{0} converts to {1}.", trueFlag, trueFlag.ToUInt64());
|
||||||
/// Console.WriteLine("{0} converts to {1}.", trueFlag,
|
|
||||||
/// trueFlag.ToUInt64());
|
|
||||||
/// // The example displays the following output:
|
/// // The example displays the following output:
|
||||||
/// // False converts to 0.
|
/// // False converts to 0.
|
||||||
/// // True converts to 1.
|
/// // True converts to 1.
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </example>
|
/// </example>
|
||||||
|
/// <seealso cref="Int64Extensions.Int64Extensions.ToBoolean(long)" />
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public static ulong ToUInt64(this bool value)
|
public static ulong ToUInt64(this bool value)
|
||||||
{
|
{
|
||||||
return value.ToByte();
|
return value ? 1UL : 0UL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user