NumberText: Converting numbers into words in C#
I created a project over the weekend called NumberText which provides a ToText()
method that will return the textual representation of an integer.
Let's say that we have the number 1234567
and want to output one million two hundred thirty four thousand five hundred sixty seven
. Using an extension method, we can call ToText()
directly on an integer data type which gives the perception that ToText()
is built right in to the .NET framework.
using System;
using NumberText;
namespace UsageExample {
class NumberTextExample {
static void Main(string[] args) {
int testNumber = 1234567;
Console.WriteLine(testNumber.ToText());
Console.WriteLine(98765.ToText());
Console.ReadKey();
}
}
}
Getting started with NumberText is super simple. Either add a reference to the NumberText.dll in your project, or add the NumberText.cs class in for more fine-grained control.
NumberText is hosted on Github under the Open Source Public License.
Subscribe for Free
Want to stay ahead of the curve? Subscribe now to receive the latest updates, actionable insights, and thought-provoking ideas around business, technology, and leadership straight to your inbox.