-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fa915e
commit c9b2b39
Showing
5 changed files
with
1,271 additions
and
967 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace DNX.Extensions.Strings; | ||
|
||
public static class BuiltInTypesExtensions | ||
{ | ||
/// <summary> | ||
/// Converts a boolean to text. | ||
/// </summary> | ||
/// <param name="value">if set to <c>true</c> [value].</param> | ||
/// <param name="trueText">The true text.</param> | ||
/// <param name="falseText">The false text.</param> | ||
/// <returns></returns> | ||
public static string ToText(this bool value, string trueText = "True", string falseText = "False") | ||
{ | ||
return value ? trueText : falseText; | ||
} | ||
|
||
/// <summary> | ||
/// Converts a boolean to text, using "Yes" and "No" | ||
/// </summary> | ||
/// <param name="value">if set to <c>true</c> [value].</param> | ||
/// <returns></returns> | ||
public static string ToYesNo(this bool value) => value.ToText("Yes", "No"); | ||
|
||
/// <summary> | ||
/// Converts an int32 to hexstring. | ||
/// </summary> | ||
/// <param name="input">The input.</param> | ||
/// <param name="format">The format.</param> | ||
/// <returns></returns> | ||
public static string ToHexString(this int input, string format = "X2") | ||
{ | ||
return input.ToString(format); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.