Skip to main content
Version: 2.13.14

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, 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

System.String

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

System.String

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

System.String

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

System.String

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

System.String

Example

Russian:

1.ToWords(GrammaticalGender.Masculine) -> "один"
1.ToWords(GrammaticalGender.Feminine) -> "одна"

Hebrew:

1.ToWords(GrammaticalGender.Masculine) -> "אחד"
1.ToWords(GrammaticalGender.Feminine) -> "אחת"

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

System.String

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

System.String

Example

Russian:

1.ToWords(GrammaticalGender.Masculine) -> "один"
1.ToWords(GrammaticalGender.Feminine) -> "одна"

Hebrew:

1.ToWords(GrammaticalGender.Masculine) -> "אחד"
1.ToWords(GrammaticalGender.Feminine) -> "אחת"

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.

Returns

System.String