Humanizer.NumberToWordsExtension
NumberToWordsExtension Class
Transform a number into words; e.g. 1 => one
public static class NumberToWordsExtension
Inheritance System.Object → NumberToWordsExtension
Methods
NumberToWordsExtension.ToOrdinalWords(this int, GrammaticalGender, WordForm, CultureInfo) Method
Converts a number to ordinal words supporting locale's specific variations.
public static string ToOrdinalWords(this int number, Humanizer.GrammaticalGender gender, Humanizer.WordForm wordForm, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to ordinal words
gender GrammaticalGender
The grammatical gender to use for output words
wordForm WordForm
Form of the word, i.e. abbreviation
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
System.String
The number converted into ordinal words
Example
In Spanish:
3.ToOrdinalWords(GrammaticalGender.Masculine, WordForm.Normal) -> "tercero"
3.ToOrdinalWords(GrammaticalGender.Masculine, WordForm.Abbreviation) -> "tercer"
3.ToOrdinalWords(GrammaticalGender.Feminine, WordForm.Normal) -> "tercera"
3.ToOrdinalWords(GrammaticalGender.Feminine, WordForm.Abbreviation) -> "tercera"
NumberToWordsExtension.ToOrdinalWords(this int, GrammaticalGender, CultureInfo) Method
for Brazilian Portuguese locale 1.ToOrdinalWords(GrammaticalGender.Masculine) -> "primeiro" 1.ToOrdinalWords(GrammaticalGender.Feminine) -> "primeira"
public static string ToOrdinalWords(this int number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to words
gender GrammaticalGender
The grammatical gender to use for output words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
NumberToWordsExtension.ToOrdinalWords(this int, WordForm, CultureInfo) Method
Converts a number to ordinal words supporting locale's specific variations.
public static string ToOrdinalWords(this int number, Humanizer.WordForm wordForm, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to ordinal words
wordForm WordForm
Form of the word, i.e. abbreviation
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
System.String
The number converted into ordinal words
Example
In Spanish:
1.ToOrdinalWords(WordForm.Normal) -> "primero" // As in "He llegado el primero".
3.ToOrdinalWords(WordForm.Abbreviation) -> "tercer" // As in "Vivo en el tercer piso"
NumberToWordsExtension.ToOrdinalWords(this int, CultureInfo) Method
1.ToOrdinalWords() -> "first"
public static string ToOrdinalWords(this int number, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to ordinal words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
NumberToWordsExtension.ToTuple(this int, CultureInfo) Method
1.ToTuple() -> "single"
public static string ToTuple(this int number, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to tuple
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
NumberToWordsExtension.ToWords(this int, bool, WordForm, CultureInfo) Method
Converts a number to words supporting specific word variations of some locales.
public static string ToWords(this int number, bool addAnd, Humanizer.WordForm wordForm, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to words
addAnd System.Boolean
To add 'and' before the last number
wordForm WordForm
Form of the word, i.e. abbreviation
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
System.String
The number converted to words
Example
In Spanish, numbers ended in 1 changes its form depending on their position in the sentence.
21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno".
21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches"
NumberToWordsExtension.ToWords(this int, bool, CultureInfo) Method
3501.ToWords(false) -> "three thousand five hundred one"
public static string ToWords(this int number, bool addAnd, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to words
addAnd System.Boolean
To add 'and' before the last number.
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
NumberToWordsExtension.ToWords(this int, GrammaticalGender, CultureInfo) Method
For locales that support gender-specific forms
public static string ToWords(this int number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to words
gender GrammaticalGender
The grammatical gender to use for output words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
Example
Russian:
1.ToWords(GrammaticalGender.Masculine) -> "один"
1.ToWords(GrammaticalGender.Feminine) -> "одна"
Hebrew:
1.ToWords(GrammaticalGender.Masculine) -> "אחד"
1.ToWords(GrammaticalGender.Feminine) -> "אחת"
NumberToWordsExtension.ToWords(this int, WordForm, GrammaticalGender, CultureInfo) Method
Converts a number to words supporting specific word variations, including grammatical gender, of some locales.
public static string ToWords(this int number, Humanizer.WordForm wordForm, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to words
wordForm WordForm
Form of the word, i.e. abbreviation
gender GrammaticalGender
The grammatical gender to use for output words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
System.String
The number converted to words
Example
In Spanish, numbers ended in 1 change its form depending on their position in the sentence.
21.ToWords(WordForm.Normal, GrammaticalGender.Masculine) -> veintiuno // as in "Mi número favorito es el veintiuno".
21.ToWords(WordForm.Abbreviation, GrammaticalGender.Masculine) -> veintiún // as in "En total, conté veintiún coches"
21.ToWords(WordForm.Normal, GrammaticalGender.Feminine) -> veintiuna // as in "veintiuna personas"
NumberToWordsExtension.ToWords(this int, WordForm, CultureInfo) Method
Converts a number to words supporting specific word variations, including grammatical gender, of some locales.
public static string ToWords(this int number, Humanizer.WordForm wordForm, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to words
wordForm WordForm
Form of the word, i.e. abbreviation
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
System.String
The number converted to words
Example
In Spanish, numbers ended in 1 change its form depending on their position in the sentence.
21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno".
21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches"
NumberToWordsExtension.ToWords(this int, CultureInfo) Method
3501.ToWords() -> "three thousand five hundred and one"
public static string ToWords(this int number, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int32
Number to be turned to words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
NumberToWordsExtension.ToWords(this long, GrammaticalGender, CultureInfo) Method
For locales that support gender-specific forms
public static string ToWords(this long number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int64
Number to be turned to words
gender GrammaticalGender
The grammatical gender to use for output words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
Example
Russian:
1.ToWords(GrammaticalGender.Masculine) -> "один"
1.ToWords(GrammaticalGender.Feminine) -> "одна"
Hebrew:
1.ToWords(GrammaticalGender.Masculine) -> "אחד"
1.ToWords(GrammaticalGender.Feminine) -> "אחת"
NumberToWordsExtension.ToWords(this long, WordForm, GrammaticalGender, CultureInfo) Method
Converts a number to words supporting specific word variations, including grammatical gender, of some locales.
public static string ToWords(this long number, Humanizer.WordForm wordForm, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo? culture=null);
Parameters
number System.Int64
Number to be turned to words
wordForm WordForm
Form of the word, i.e. abbreviation
gender GrammaticalGender
The grammatical gender to use for output words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
Returns
System.String
The number converted to words
Example
In Spanish, numbers ended in 1 changes its form depending on their position in the sentence.
21.ToWords(WordForm.Normal, GrammaticalGender.Masculine) -> veintiuno // as in "Mi número favorito es el veintiuno".
21.ToWords(WordForm.Abbreviation, GrammaticalGender.Masculine) -> veintiún // as in "En total, conté veintiún coches"
21.ToWords(WordForm.Normal, GrammaticalGender.Feminine) -> veintiuna // as in "veintiuna personas"
NumberToWordsExtension.ToWords(this long, WordForm, CultureInfo, bool) Method
Converts a number to words supporting specific word variations of some locales.
public static string ToWords(this long number, Humanizer.WordForm wordForm, System.Globalization.CultureInfo? culture=null, bool addAnd=false);
Parameters
number System.Int64
Number to be turned to words
wordForm WordForm
Form of the word, i.e. abbreviation
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
addAnd System.Boolean
To add 'and' before the last number
Returns
System.String
The number converted to words
Example
In Spanish, numbers ended in 1 changes its form depending on their position in the sentence.
21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno".
21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches"
NumberToWordsExtension.ToWords(this long, CultureInfo, bool) Method
3501.ToWords() -> "three thousand five hundred and one"
public static string ToWords(this long number, System.Globalization.CultureInfo? culture=null, bool addAnd=true);
Parameters
number System.Int64
Number to be turned to words
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
addAnd System.Boolean
Whether "and" should be included or not.