Add BooleanExtensions

ToInt32() returns 1 if value is true, 0 otherwise
This commit is contained in:
Oliver Booth 2019-11-16 01:51:06 +00:00
parent cae360edc3
commit 445929e1b8
No known key found for this signature in database
GPG Key ID: 4B0992B2602C3778
2 changed files with 23 additions and 0 deletions

22
X10D/BooleanExtensions.cs Normal file
View File

@ -0,0 +1,22 @@
namespace X10D
{
#region Using Directives
using System;
#endregion
/// <summary>
/// Extension methods for <see cref="Boolean"/>.
/// </summary>
public static class BooleanExtensions
{
/// <summary>
/// Gets an integer value that represents this boolean.
/// </summary>
/// <param name="value">The boolean.</param>
/// <returns>Returns 1 if <paramref name="value"/> is <see langword="true"/>, 0 otherwise.</returns>
public static int ToInt32(this bool value) =>
value ? 1 : 0;
}
}

View File

@ -44,6 +44,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BooleanExtensions.cs" />
<Compile Include="ByteExtensions.cs" /> <Compile Include="ByteExtensions.cs" />
<Compile Include="CharExtensions.cs" /> <Compile Include="CharExtensions.cs" />
<Compile Include="ConvertibleExtensions.cs" /> <Compile Include="ConvertibleExtensions.cs" />