Convert an integer to a string of words

Possible duplicate:
C # Convert integers to number of written numbers

I need to take an integer value and convert it to its English word, equivalent (for example, 4 => "four", 1879 => "one thousand eight hundred seventy nine") in .NET (3.5 for specific).

I am wondering if there is anything built into the .NET framework for such a conversion. It seems like it would be useful enough to be there. I could not find anything to do this job.

If it’s not included anywhere in the structure, does anyone have any more elegant ideas than searching by type / location?

+4
source share
7 answers

This is like a trick until you deal with trillions.

http://weblogs.asp.net/Justin_Rogers/archive/2004/06/09/151675.aspx

edit: here is a working link to something similar https://www.exchangecore.com/blog/convert-number-words-c-sharp-console-application/

+2
source

Check out this link: Functional Fun: Euler 17 for LINQ.

+2
source

string s is the input number

const string input = "1023"; string[] placement = { "thousand", "hundred", "ten", "" }; string[] numbersToLetters = { "", "one", "two", "tre", "four", "five", "six", "seven", "eight", "nine" }; for (int i = 0; i < input.Length; i++) { int digits = input[i] != '0' ? (placement.Length - input.Length) + i : 3; int result = int.Parse(input[i].ToString()); var type = placement[digits]; var number = numbersToLetters[result]; Console.WriteLine(number + type); } 
+2
source

I don’t know anything about this. You just need to make out the figure a bit and replace it.

I found several examples on the net:

http://www.dotnetspider.com/resources/2743-Code-Convert-numbers-word.aspx http://www.codeproject.com/KB/cs/codesamples.aspx

0
source

There is no direct function to convert and create text forms for you. You will need to write your program, where, in essence, you will have to write down the values ​​of all the digits, i.e. 1, 2, ..., 9 nine. Then you have to take care of tens, hundreds, thousands, and then you have to write logic to extract numbers and add words accordingly.

0
source

Nothing built in. Here is a way to do it.

0
source

All Articles