Introduction
NumberText: Converting numbers into words in C#
Technology

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.

Robert Greiner
Author

Robert Greiner

Professional optimist. Passionate about cultivating high-performing teams @ scale by integrating the timeless wisdom of the past with the marvel of today's emergent technology in a practical way.

View Comments
Next Post

How to get a temp directory in any OS with Ruby

Previous Post

Later Equals Never

Subscribe for free

Subscribe to my newsletter and get the latest posts delivered right to your inbox for free. I don't spam and your email won't be shared with third-parties.

Thanks for subscribing!

Check your inbox to confirm your subscription.

Please enter a valid email address!