C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Base Blockchain
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Vibe Coding
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
7
Answers
How to create custom helper for converting Number to word
Raju Fodse
4y
550
1
Reply
I am developing web app using I want to display currency amount in word and I want to use custome HTML helper. How can I call function in HTML Helper.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Mvc;
namespace
EasyApp.Models
{
public
static
class
NWConverter
{
public
static
IHtmlString Retrieve_Label(
this
HtmlHelper helper)
{
//I want use this html helper
}
public
string
Rupees(Int32 rup)
{
string
result =
""
;
Int32 res;
if
((rup / 10000000) > 0)
{
res = rup / 10000000;
rup = rup % 10000000;
result = result +
' '
+ RupeesToWords(res) +
" Crore"
;
}
if
((rup / 100000) > 0)
{
res = rup / 100000;
rup = rup % 100000;
result = result +
' '
+ RupeesToWords(res) +
" Lack"
;
}
if
((rup / 1000) > 0)
{
res = rup / 1000;
rup = rup % 1000;
result = result +
' '
+ RupeesToWords(res) +
" Thousand"
;
}
if
((rup / 100) > 0)
{
res = rup / 100;
rup = rup % 100;
result = result +
' '
+ RupeesToWords(res) +
" Hundred"
;
}
if
((rup % 10) >= 0)
{
res = rup % 100;
result = result +
" "
+ RupeesToWords(res);
}
result = result +
' '
+
" Rupees only"
;
return
result;
}
public
string
RupeesToWords(Int32 rup)
{
string
result =
""
;
if
((rup >= 1) && (rup <= 10))
{
if
((rup % 10) == 1) result =
"One"
;
if
((rup % 10) == 2) result =
"Two"
;
if
((rup % 10) == 3) result =
"Three"
;
if
((rup % 10) == 4) result =
"Four"
;
if
((rup % 10) == 5) result =
"Five"
;
if
((rup % 10) == 6) result =
"Six"
;
if
((rup % 10) == 7) result =
"Seven"
;
if
((rup % 10) == 8) result =
"Eight"
;
if
((rup % 10) == 9) result =
"Nine"
;
if
((rup % 10) == 0) result =
"Ten"
;
}
if
(rup > 9 && rup < 20)
{
if
(rup == 11) result =
"Eleven"
;
if
(rup == 12) result =
"Twelve"
;
if
(rup == 13) result =
"Thirteen"
;
if
(rup == 14) result =
"Forteen"
;
if
(rup == 15) result =
"Fifteen"
;
if
(rup == 16) result =
"Sixteen"
;
if
(rup == 17) result =
"Seventeen"
;
if
(rup == 18) result =
"Eighteen"
;
if
(rup == 19) result =
"Nineteen"
;
}
if
(rup > 20 && (rup / 10) == 2 && (rup % 10) == 0) result =
"Twenty"
;
if
(rup > 20 && (rup / 10) == 3 && (rup % 10) == 0) result =
"Thirty"
;
if
(rup > 20 && (rup / 10) == 4 && (rup % 10) == 0) result =
"Forty"
;
if
(rup > 20 && (rup / 10) == 5 && (rup % 10) == 0) result =
"Fifty"
;
if
(rup > 20 && (rup / 10) == 6 && (rup % 10) == 0) result =
"Sixty"
;
if
(rup > 20 && (rup / 10) == 7 && (rup % 10) == 0) result =
"Seventy"
;
if
(rup > 20 && (rup / 10) == 8 && (rup % 10) == 0) result =
"Eighty"
;
if
(rup > 20 && (rup / 10) == 9 && (rup % 10) == 0) result =
"Ninty"
;
if
(rup > 20 && (rup / 10) == 2 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Twenty One"
;
if
((rup % 10) == 2) result =
"Twenty Two"
;
if
((rup % 10) == 3) result =
"Twenty Three"
;
if
((rup % 10) == 4) result =
"Twenty Four"
;
if
((rup % 10) == 5) result =
"Twenty Five"
;
if
((rup % 10) == 6) result =
"Twenty Six"
;
if
((rup % 10) == 7) result =
"Twenty Seven"
;
if
((rup % 10) == 8) result =
"Twenty Eight"
;
if
((rup % 10) == 9) result =
"Twenty Nine"
;
}
if
(rup > 20 && (rup / 10) == 3 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Thirty One"
;
if
((rup % 10) == 2) result =
"Thirty Two"
;
if
((rup % 10) == 3) result =
"Thirty Three"
;
if
((rup % 10) == 4) result =
"Thirty Four"
;
if
((rup % 10) == 5) result =
"Thirty Five"
;
if
((rup % 10) == 6) result =
"Thirty Six"
;
if
((rup % 10) == 7) result =
"Thirty Seven"
;
if
((rup % 10) == 8) result =
"Thirty Eight"
;
if
((rup % 10) == 9) result =
"Thirty Nine"
;
}
if
(rup > 20 && (rup / 10) == 4 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Forty One"
;
if
((rup % 10) == 2) result =
"Forty Two"
;
if
((rup % 10) == 3) result =
"Forty Three"
;
if
((rup % 10) == 4) result =
"Forty Four"
;
if
((rup % 10) == 5) result =
"Forty Five"
;
if
((rup % 10) == 6) result =
"Forty Six"
;
if
((rup % 10) == 7) result =
"Forty Seven"
;
if
((rup % 10) == 8) result =
"Forty Eight"
;
if
((rup % 10) == 9) result =
"Forty Nine"
;
}
if
(rup > 20 && (rup / 10) == 5 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Fifty One"
;
if
((rup % 10) == 2) result =
"Fifty Two"
;
if
((rup % 10) == 3) result =
"Fifty Three"
;
if
((rup % 10) == 4) result =
"Fifty Four"
;
if
((rup % 10) == 5) result =
"Fifty Five"
;
if
((rup % 10) == 6) result =
"Fifty Six"
;
if
((rup % 10) == 7) result =
"Fifty Seven"
;
if
((rup % 10) == 8) result =
"Fifty Eight"
;
if
((rup % 10) == 9) result =
"Fifty Nine"
;
}
if
(rup > 20 && (rup / 10) == 6 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Sixty One"
;
if
((rup % 10) == 2) result =
"Sixty Two"
;
if
((rup % 10) == 3) result =
"Sixty Three"
;
if
((rup % 10) == 4) result =
"Sixty Four"
;
if
((rup % 10) == 5) result =
"Sixty Five"
;
if
((rup % 10) == 6) result =
"Sixty Six"
;
if
((rup % 10) == 7) result =
"Sixty Seven"
;
if
((rup % 10) == 8) result =
"Sixty Eight"
;
if
((rup % 10) == 9) result =
"Sixty Nine"
;
}
if
(rup > 20 && (rup / 10) == 7 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Seventy One"
;
if
((rup % 10) == 2) result =
"Seventy Two"
;
if
((rup % 10) == 3) result =
"Seventy Three"
;
if
((rup % 10) == 4) result =
"Seventy Four"
;
if
((rup % 10) == 5) result =
"Seventy Five"
;
if
((rup % 10) == 6) result =
"Seventy Six"
;
if
((rup % 10) == 7) result =
"Seventy Seven"
;
if
((rup % 10) == 8) result =
"Seventy Eight"
;
if
((rup % 10) == 9) result =
"Seventy Nine"
;
}
if
(rup > 20 && (rup / 10) == 8 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Eighty One"
;
if
((rup % 10) == 2) result =
"Eighty Two"
;
if
((rup % 10) == 3) result =
"Eighty Three"
;
if
((rup % 10) == 4) result =
"Eighty Four"
;
if
((rup % 10) == 5) result =
"Eighty Five"
;
if
((rup % 10) == 6) result =
"Eighty Six"
;
if
((rup % 10) == 7) result =
"Eighty Seven"
;
if
((rup % 10) == 8) result =
"Eighty Eight"
;
if
((rup % 10) == 9) result =
"Eighty Nine"
;
}
if
(rup > 20 && (rup / 10) == 9 && (rup % 10) != 0)
{
if
((rup % 10) == 1) result =
"Ninty One"
;
if
((rup % 10) == 2) result =
"Ninty Two"
;
if
((rup % 10) == 3) result =
"Ninty Three"
;
if
((rup % 10) == 4) result =
"Ninty Four"
;
if
((rup % 10) == 5) result =
"Ninty Five"
;
if
((rup % 10) == 6) result =
"Ninty Six"
;
if
((rup % 10) == 7) result =
"Ninty Seven"
;
if
((rup % 10) == 8) result =
"Ninty Eight"
;
if
((rup % 10) == 9) result =
"Ninty Nine"
;
}
return
result;
}
}
}
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
How you get Degree minute and seconds from lat/lng
Web Api In Asp.net Mvc ApiControlar