Provides extensions for formatting a System.String word as a quantity.
public static class ToQuantityExtensionsInheritance System.Object → ToQuantityExtensions
Prefixes the provided word with the number and accordingly pluralizes or singularizes the word
public static string ToQuantity(this string input, double quantity);input System.String
The word to be prefixed
quantity System.Double
The quantity of the word
"request".ToQuantity(0.2) => "0.2 requests"
Prefixes the provided word with the number and accordingly pluralizes or singularizes the word
public static string ToQuantity(this string input, double quantity, string? format=null, System.IFormatProvider? formatProvider=null);input System.String
The word to be prefixed
quantity System.Double
The quantity of the word
format System.String
A standard or custom numeric format string.
formatProvider System.IFormatProvider
An object that supplies culture-specific formatting information.
"request".ToQuantity(0.2) => "0.2 requests" "request".ToQuantity(10.6, format: "N0") => "10.6 requests" "request".ToQuantity(1.0, format: "N0") => "1 request"
Prefixes the provided word with the number and accordingly pluralizes or singularizes the word
public static string ToQuantity(this string input, int quantity, Humanizer.ShowQuantityAs showQuantityAs=Humanizer.ShowQuantityAs.Numeric);input System.String
The word to be prefixed
quantity System.Int32
The quantity of the word
showQuantityAs ShowQuantityAs
How to show the quantity. Numeric by default
"request".ToQuantity(0) => "0 requests" "request".ToQuantity(1) => "1 request" "request".ToQuantity(2) => "2 requests" "men".ToQuantity(2) => "2 men" "process".ToQuantity(1200, ShowQuantityAs.Words) => "one thousand two hundred processes"
Prefixes the provided word with the number and accordingly pluralizes or singularizes the word
public static string ToQuantity(this string input, int quantity, string? format, System.IFormatProvider? formatProvider=null);input System.String
The word to be prefixed
quantity System.Int32
The quantity of the word
format System.String
A standard or custom numeric format string.
formatProvider System.IFormatProvider
An object that supplies culture-specific formatting information.
"request".ToQuantity(0) => "0 requests" "request".ToQuantity(10000, format: "N0") => "10,000 requests" "request".ToQuantity(1, format: "N0") => "1 request"
Prefixes the provided word with the number and accordingly pluralizes or singularizes the word
public static string ToQuantity(this string input, long quantity, Humanizer.ShowQuantityAs showQuantityAs=Humanizer.ShowQuantityAs.Numeric);input System.String
The word to be prefixed
quantity System.Int64
The quantity of the word
showQuantityAs ShowQuantityAs
How to show the quantity. Numeric by default
"request".ToQuantity(0) => "0 requests" "request".ToQuantity(1) => "1 request" "request".ToQuantity(2) => "2 requests" "men".ToQuantity(2) => "2 men" "process".ToQuantity(1200, ShowQuantityAs.Words) => "one thousand two hundred processes"
Prefixes the provided word with the number and accordingly pluralizes or singularizes the word
public static string ToQuantity(this string input, long quantity, string? format, System.IFormatProvider? formatProvider=null);input System.String
The word to be prefixed
quantity System.Int64
The quantity of the word
format System.String
A standard or custom numeric format string.
formatProvider System.IFormatProvider
An object that supplies culture-specific formatting information.
"request".ToQuantity(0) => "0 requests" "request".ToQuantity(10000, format: "N0") => "10,000 requests" "request".ToQuantity(1, format: "N0") => "1 request"