Resources » Code Snippets » C# Syntax

Convert numbers to words(Hindi Unicode)


Posted Date: 29-Apr-2010  Last Updated:   Category: C# Syntax    
Author: Member Level: Silver    Points: 6


If u want to convert Numbers in words U can use that Code that will convert your number into word (Hindi Unicode). U cam modify it as your requirements and needs.



If u want to convert Numbers in words U can use that Code that will convert your number into word (Hindi Unicode). U cam modify it as your requirements and needs.


Here ???? is Unicode thats is not display proper here for that download attachment File

Here is the Function for converting into words


public static String ConvToWordRupee(decimal Amount)
{
if (Amount == 0)
return "";

string strConv="";
string strAmount = Amount.ToString().Trim();
int IndexDot=strAmount.IndexOf('.');
strAmount=strAmount.Substring(0, IndexDot);
int Len = strAmount.Length;
string Temp = "";
if (Len == 8 || Len == 9)
{
if (Len == 8)
{
strAmount = "0" + strAmount;
Len = strAmount.Length;
}

Temp = strAmount.Substring(0, Len - 7);
Temp = GetTen(Temp);
if (Temp != "")
{
strConv += Temp;
strConv += " ????? ";
}
Len = Len - 2;
strAmount = strAmount.Substring(2, Len);
}

if (Len == 6 || Len == 7)
{
if (Len == 6)
{
strAmount = "0" + strAmount;
Len = strAmount.Length;
}

Temp = strAmount.Substring(0, Len - 5);
Temp=GetTen(Temp);
if (Temp != "")
{
strConv += Temp;
strConv += " ??? ";
}
Len = Len - 2;
strAmount = strAmount.Substring(2, Len);
}
if (Len == 4 || Len == 5)
{
if (Len == 4)
{
strAmount = "0" + strAmount;
Len = strAmount.Length;
}

Temp = strAmount.Substring(0, Len - 3);
Temp = GetTen(Temp);
if (Temp != "")
{
strConv += Temp;
strConv += " ???? ";
}
Len = Len - 2;
strAmount = strAmount.Substring(2, Len);
}
if (Len == 3)
{
Temp = strAmount.Substring(0, Len - 2);
Temp = GetTen(Temp);
if (Temp != "")
{
strConv += Temp;
strConv += " ?? ";
}
Len = Len - 1;
}
if (Len == 2 || Len==1)
{
Temp = strAmount;
Temp= GetTen(Temp);
if(Temp=="")
{
strConv += Temp;
}
}
strConv += " ????? ????? |";
return strConv;
//???
//????
}
private static string GetTen(string Num)
{
string strNum = "";
switch(Convert.ToInt16(Num))
{
case 1:
strNum = "??";
break;
case 2:
strNum = "??";
break;
case 3:
strNum = "???";
break;
case 4:
strNum = "???";
break;
case 5:
strNum = "????";
break;
case 6:
strNum = "??";
break;
case 7:
strNum = "???";
break;
case 8:
strNum = "??";
break;
case 9:
strNum = "??";
break;
case 10:
strNum = "??";
break;
case 11:
strNum = "??????";
break;
case 12:
strNum = "????";
break;
case 13:
strNum = "????";
break;
case 14:
strNum = "????";
break;
case 15:
strNum = "??????";
break;
case 16:
strNum = "????";
break;
case 17:
strNum = "??????";
break;
case 18:
strNum = "?????";
break;
case 19:
strNum = "??????";
break;
case 20:
strNum = "???";
break;
case 21:
strNum = "??????";
break;
case 22:
strNum = "????";
break;
case 23:
strNum = "????";
break;
case 24:
strNum = "?????";
break;
case 25:
strNum = "??????";
break;
case 26:
strNum = "??????";
break;
case 27:
strNum = "???????";
break;
case 28:
strNum = "???????";
break;
case 29:
strNum = "?????";
break;
case 30:
strNum = "???";
break;
case 31:
strNum = "?????";
break;
case 32:
strNum = "??????";
break;
case 33:
strNum = "??????";
break;
case 34:
strNum = "??????";
break;
case 35:
strNum = "??????";
break;
case 36:
strNum = "??????";
break;
case 37:
strNum = "??????";
break;
case 38:
strNum = "??????";
break;
case 39:
strNum = "???????";
break;
case 40:
strNum = "?????";
break;
case 41:
strNum = "???????";
break;
case 42:
strNum = "??????";
break;
case 43:
strNum = "????????";
break;
case 44:
strNum = "???????";
break;
case 45:
strNum = "????????";
break;
case 46:
strNum = "???????";
break;
case 47:
strNum = "????????";
break;
case 48:
strNum = "????????";
break;
case 49:
strNum = "?????";
break;
case 50:
strNum = "????";
break;
case 51:
strNum = "???????";
break;
case 52:
strNum = "????";
break;
case 53:
strNum = "??????";
break;
case 54:
strNum = "????";
break;
case 55:
strNum = "????";
break;
case 56:
strNum = "?????";
break;
case 57:
strNum = "???????";
break;
case 58:
strNum = "???????";
break;
case 59:
strNum = "????";
break;
case 60:
strNum = "???";
break;
case 61:
strNum = "????";
break;
case 62:
strNum = "????";
break;
case 63:
strNum = "??????";
break;
case 64:
strNum = "?????";
break;
case 65:
strNum = "?????";
break;
case 66:
strNum = "??????";
break;
case 67:
strNum = "?????";
break;
case 68:
strNum = "?????";
break;
case 69:
strNum = "???????";
break;
case 70:
strNum = "?????";
break;
case 71:
strNum = "???????";
break;
case 72:
strNum = "??????";
break;
case 73:
strNum = "???????";
break;
case 74:
strNum = "???????";
break;
case 75:
strNum = "???????";
break;
case 76:
strNum = "???????";
break;
case 77:
strNum = "???????";
break;
case 78:
strNum = "???????";
break;
case 79:
strNum = "?????";
break;
case 80:
strNum = "?????";
break;
case 81:
strNum = "???????";
break;
case 82:
strNum = "?????";
break;
case 83:
strNum = "??????";
break;
case 84:
strNum = "??????";
break;
case 85:
strNum = "?????";
break;
case 86:
strNum = "??????";
break;
case 87:
strNum = "???????";
break;
case 88:
strNum = "???????";
break;
case 89:
strNum = "?????";
break;
case 90:
strNum = "?????";
break;
case 91:
strNum = "????????";
break;
case 92:
strNum = "?????";
break;
case 93:
strNum = "???????";
break;
case 94:
strNum = "???????";
break;
case 95:
strNum = "???????";
break;
case 96:
strNum = "???????";
break;
case 97:
strNum = "????????";
break;
case 98:
strNum = "????????";
break;
case 99:
strNum = "?????????";
break;
}
return strNum;
}
public Decimal decVal(String str)
{
try
{
if (str == "")
{
return 0;
}
else
{
return Convert.ToDecimal(str);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
}


Read related articles: Unicode    Hindi Unicode    

Did you like this resource? Share it with your friends and show your love!

Responses to "Convert numbers to words(Hindi Unicode)"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Ram Prasad
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India