Humanizer
Humanizer copied to clipboard
Humanize for boolean types
I would like to know if there is or will be support for the "Humanize" method for Boolean types.
Could you provide some examples that you have in mind?
While this by no means following the pattern in this project, an extension method is how I accomplish this and would be happy to submit a PR with this support matching the expected project behavior.
public static class BooleanExtensions
{
/// <summary>
/// Returns human readable string of Yes/No for the given boolean
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static string ToHuman(this bool val)
{
return val.ToString().Replace("False", "No").Replace("True", "Yes");
}
}
I would suggest to write own extension method as it is much easier.
public static string Humanize(this bool val) => val ? "Yes" : "No";
Not sure why would someone want this as a library.