Amount In Words or Numbers Into Words In C#

In this article we will see that how convert numbers into words and display as amount (currency, Rupees) in c# programming language, this functionality often require in C# Window / Web Application

Amount In Words : Most commonly asked question by developers and students that how to show Price or Amount in Invoice by converting numbers into word.

here is an example

public string wordtonumber(long number)
        {   string word = "";
            if (number == 0)
            {
                word += "Zero";
            }
            if ((number / 100000) > 0)
            {
                word += wordtonumber(number / 100000) + " Lakh ";
                number %= 100000;
            }
            if ((number / 1000) > 0)
            {
                word += wordtonumber((number / 1000)) + " thousand ";
                number %= 1000;
            }
            if ((number / 100) > 0)
            {
                word += wordtonumber((number / 100)) + " hundred ";
                number %= 100;
            }
            if (number > 0)
            {
                var unitmap = new[] {"One", "Two", "Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen",
                    "Nineteen" };
                var tensMap = new[] { "Ten", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eight", "Ninety" };
                if (number < 20)
                {
                    word += " " + unitmap[number-1];
                }
                else {
                    word += tensMap[(number / 10) - 1];
                    if ((number % 10) > 0)
                        word += " "+ unitmap[(number % 10) - 1];
                    
                }
            }
            return word;
        }

now you have to just simply call this function and it will return result in Amount (Currency)

long numbers = 1255355;
string amount = wordtonumber(numbers);
amount = amount + " Rupees"; //append Rupees 

Output

output image
output

Share this article

Leave a Comment

Your email address will not be published. Required fields are marked *