Click here to Skip to main content
13,833,606 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 12 May 2013
Licenced CPOL

Converting numbers to the word equivalent.

, 12 May 2013
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "Converting numbers to the word equivalent. "


This is an alternative Tip for Converting numbers to the word equivalent. by OriginalGriff.

Using the Code

After looking at the code of OriginalGriff, I found a shorter alternative:

static string[] numbers = new string[] { 
    ... ,
    "Five hundred and sixty-eight",
    "Five hundred and sixty-nine",
public static string ConvertToWords(int number)
    if (number < 0)
        return "Negative numbers not supported";
    else if (numbers.Length > number)
        return numbers[number];
        return "Number too large";

Please note: you have to start with "Zero", otherwise the code don't will work. And if you end with "Thousand" for example, you have to add each number from 0 to 1000. If you forget "Five" for example, my code don't will work properly.

Advantages of my code:
  • Shorter (If you add three values to the array, my code isn't shorter. However, if you add 100 values to the array, my code is shorter than the code of OriginalGriff)
  • Faster at runtime
  • It costs more memory


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Thomas Daniels
Belgium Belgium
Also known as ProgramFOX. I like programming, playing chess and astronomy. Administrator of Chess Variants Training[^].

Find me on:

You may also be interested in...

Comments and Discussions

QuestionMy (late) vote of 5 Pin
CHill6022-Oct-14 1:10
protectorCHill6022-Oct-14 1:10 
GeneralRe: My (late) vote of 5 Pin
Thomas Daniels22-Oct-14 3:16
mveThomas Daniels22-Oct-14 3:16 
GeneralMy vote of 5 Pin
Matt T Heffron13-May-13 12:47
professionalMatt T Heffron13-May-13 12:47 
GeneralMy vote of 5 Pin
keefe higgins13-May-13 6:40
memberkeefe higgins13-May-13 6:40 
Question+5 Pin
Simon_Whale12-May-13 23:34
professionalSimon_Whale12-May-13 23:34 
AnswerRe: +5 Pin
Thomas Daniels13-May-13 7:40
mveThomas Daniels13-May-13 7:40 
QuestionDown votes compensated Pin
OriginalGriff12-May-13 22:28
protectorOriginalGriff12-May-13 22:28 
GeneralMy vote of 1 Pin
Klaus Luedenscheidt12-May-13 20:28
memberKlaus Luedenscheidt12-May-13 20:28 
GeneralMy vote of 1 Pin
Singh Vijay Kumar12-May-13 19:32
professionalSingh Vijay Kumar12-May-13 19:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190114.1 | Last Updated 12 May 2013
Article Copyright 2013 by Thomas Daniels
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid