0

This may be an akward question but is there any built in function in .net for translating an integer to a describing text?

That is, if i have the value 1 i want to print it as the string one. If the value is 22, i want the string twenty-two and so on, or do i have to build my own function/algorithm for this?

Yes, the most common is to use 0 to 9 as explaining text and ten and above displayed in numbers, but I still wonder, and I guess I can't find anything about it since it's not possible? VB or C# does not matter.

gubbfett
  • 2,157
  • 6
  • 32
  • 54
  • http://stackoverflow.com/questions/3213/convert-integers-to-written-numbers – Kiran Hegde Sep 11 '14 at 09:09
  • sorry for repost, thanks. – gubbfett Sep 11 '14 at 09:10
  • Do you require localized text? Meaning, if you do this on a norwegian computer, would you need to get "To-og-tyve"? – Lasse V. Karlsen Sep 11 '14 at 09:14
  • @LasseV.Karlsen That's my main reason why i wondered if there was a built in function for this in .net since then it would solve this problem automatically. But actually no - but if there were a built in function for this it would be "more right" to use it. – gubbfett Sep 11 '14 at 09:18

2 Answers2

1

You can use the humanizr library and then simply try like this:

Console.WriteLine(123.ToWords());

or else you may try to look at this: Converting Numbers to Words

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

You can wolfram it :

number name 123456

If you use mathematica aka wolfram language, then you have interface for it and you can use: https://mathematica.stackexchange.com/questions/1065/how-to-express-an-integer-number-in-english-words

To call Mathematica from c# you can use JLink.

It is not meant as most cost effective solution, but it is guaranteed to be right. For example 71! is

850 duotrigintillion 478 untrigintillion 588 trigintillion 567 novemvigintillion 862 octovigintillion 317 septenvigintillion 521 sexvigintillion 167 quinvigintillion 644 quattuorvigintillion 239 trevigintillion 926 duovigintillion 10 unvigintillion 288 vigintillion 584 novemdecillion 608 octodecillion 120 septendecillion 796 sexdecillion 235 quindecillion 886 quattuordecillion 430 tredecillion 763 duodecillion 388 undecillion 588 decillion 680 nonillion 378 octillion 79 septillion 17 sextillion 697 quintillion 280 quadrillion

Community
  • 1
  • 1
Margus
  • 19,694
  • 14
  • 55
  • 103