I have a field no of packages that contain (packages=)222
now i want to print that in words Two hundred and twenty two only like this i want to print in a label in c# dotnet
post solution for this
Thanks in advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mukesh KumarPosted Jan 10, 2012, 5:38 AM
Anuja PawarPosted Jan 10, 2012, 5:22 AM
Try this
VulpesPosted Jan 5, 2012, 5:43 AM
http://www.c-sharpcorner.com/uploadfile/b942f9/converting-numbers-to-words-in-C-Sharp/
Satyapriya NayakPosted Jan 5, 2012, 5:42 AM
Try this...
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default2 : System.Web.UI.Page
{
int n = 0;
string x = null;
protected void Button1_Click(object sender, EventArgs e)
{
string[] a = {
"One",
"Two",
"Three",
"four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten",
"Eleven",
"Twelve",
"Thirteen",
"fourteen",
"Fifteen",
"Sixteen",
"Seventeen",
"Eighteen",
"Ninteen"
};
string[] b = {
"Twenty",
"Thirty",
"Fourty",
"Fifty",
"sixty",
"Seventy",
"eighty",
"ninty"
};
x = "";
n = int.Parse(TextBox1.Text);
if ((n <= 9999))
{
if ((n > 999 & n <= 9999))
{
x += a[(n / 1000) - 1] + "Thousand";
n = n % 1000;
}
x += " ";
if ((n > 99 & n <= 999))
{
x += a[(n / 100) - 1] + "Hundred";
n = n % 100;
}
x += " ";
if ((n > 19 & n <= 99))
{
x += b[(n / 10) - 2];
n = n % 10;
}
x += " ";
if ((n > 0 & n <= 19))
{
x += a[n - 1];
}
TextBox2.Text = x;
}
else
{
TextBox1.Text = ("Number is out of range");
}
}
}
Thanks