I write a program in c# which convert number into word .this program work correct for me hope it will help you:
Code is:
using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ConsoleApplication1 {
Harsh ShahPosted Dec 1, 2020, 7:05 AM
Gagan SikriPosted Apr 20, 2015, 1:03 PM
http://robertgreiner.com/2011/08/numbertext-converting-numbers-into-words-in-csharp/
gbolahan lawalPosted Apr 2, 2015, 1:16 AM
Pankaj Kumar ChoudharyPosted Apr 1, 2015, 9:31 PM
Code is:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
void Convert(long num, string str)
{
string[] st ={" "," one"," two"," three"," four"," five"," six"," seven"," eight"," nine", " ten",
" eleven"," twelve"," thirteen"," fourteen"," fifteen"," sixteen"," seventeen"," eighteen"," ninteen"};
string[] st2 ={" "," "," twenty"," thirty"," fourty"," fifty"," sixty",
" seventy"," eighty"," ninty"};
if (num > 19)
Console.Write(" {0} {1} ", st2[num / 10], st[num % 10]);
else
Console.Write("{0} ", st[num]);
if (num != 0)
Console.Write("{0} ", str);
}
static void Main(string[] args)
{
long n;
Program pg = new Program();
Console.WriteLine("Enter Your Number ");
n = long.Parse(Console.ReadLine());
if (n < 0)
Console.WriteLine("Number Should be greater then 0");
else
{
pg.Convert((n / 10000000), "crore");
pg.Convert(((n / 100000) % 100), "lakh");
pg.Convert(((n / 1000) % 100), "thousand");
pg.Convert(((n / 100) % 10), "hundred");
pg.Convert((n % 100), " ");
}
Console.ReadKey();
}
}
}