TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Convert Rupees (Numbers) to Words (String) using C#.NET
Pintoo Yadav
May 06
2015
Code
54.6
k
0
4
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
public
string
ConvertNumbertoWords(
long
number)
{
if
(number == 0)
return
"ZERO"
;
if
(number < 0)
return
"minus "
+ ConvertNumbertoWords(Math.Abs(number));
string
words =
""
;
if
((number / 1000000) > 0)
{
words += ConvertNumbertoWords(number / 100000) +
" LAKES "
;
number %= 1000000;
}
if
((number / 1000) > 0)
{
words += ConvertNumbertoWords(number / 1000) +
" THOUSAND "
;
number %= 1000;
}
if
((number / 100) > 0)
{
words += ConvertNumbertoWords(number / 100) +
" HUNDRED "
;
number %= 100;
}
//if ((number / 10) > 0)
//{
// words += ConvertNumbertoWords(number / 10) + " RUPEES ";
// number %= 10;
//}
if
(number > 0)
{
if
(words !=
""
) words +=
"AND "
;
var unitsMap =
new
[]
{
"ZERO"
,
"ONE"
,
"TWO"
,
"THREE"
,
"FOUR"
,
"FIVE"
,
"SIX"
,
"SEVEN"
,
"EIGHT"
,
"NINE"
,
"TEN"
,
"ELEVEN"
,
"TWELVE"
,
"THIRTEEN"
,
"FOURTEEN"
,
"FIFTEEN"
,
"SIXTEEN"
,
"SEVENTEEN"
,
"EIGHTEEN"
,
"NINETEEN"
};
var tensMap =
new
[]
{
"ZERO"
,
"TEN"
,
"TWENTY"
,
"THIRTY"
,
"FORTY"
,
"FIFTY"
,
"SIXTY"
,
"SEVENTY"
,
"EIGHTY"
,
"NINETY"
};
if
(number < 20) words += unitsMap[number];
else
{
words += tensMap[number / 10];
if
((number % 10) > 0) words +=
" "
+ unitsMap[number % 10];
}
}
return
words;
}
Convert Number to String
Convert to String