On this article we are going to see that how convert numbers into phrases and show as quantity (foreign money, Rupees) in c# programming language, this performance usually require in C# Window / Internet Utility
Quantity In Phrases : Mostly requested query by builders and college students that learn how to present Value or Quantity in Bill by changing numbers into phrase.
right here is an instance
public string wordtonumber(lengthy quantity)
{ string phrase = "";
if (quantity == 0)
{
phrase += "Zero";
}
if ((quantity / 100000) > 0)
{
phrase += wordtonumber(quantity / 100000) + " Lakh ";
quantity %= 100000;
}
if ((quantity / 1000) > 0)
{
phrase += wordtonumber((quantity / 1000)) + " thousand ";
quantity %= 1000;
}
if ((quantity / 100) > 0)
{
phrase += wordtonumber((quantity / 100)) + " hundred ";
quantity %= 100;
}
if (quantity > 0)
{
var unitmap = new[] {"One", "Two", "Three","4","5","Six","Seven","Eight","9","Ten","Eleven","Twelve","13","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen",
"Nineteen" };
var tensMap = new[] { "Ten", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eight", "Ninety" };
if (quantity < 20)
{
phrase += " " + unitmap[number-1];
}
else {
phrase += tensMap[(number / 10) - 1];
if ((quantity % 10) > 0)
phrase += " "+ unitmap[(number % 10) - 1];
}
}
return phrase;
}
now it’s a must to simply merely name this perform and it’ll return lead to Quantity (Foreign money)
lengthy numbers = 1255355;
string quantity = wordtonumber(numbers);
quantity = quantity + " Rupees"; //append Rupees
Output
