How to Convert Whole Numbers to Currency in C#
Submitted by janobe on Tuesday, September 10, 2019 - 21:49.
If you find hard to convert whole numbers to currency, this tutorial is right for you. So, in this tutorial, I will teach you how to convert whole numbers to currency in c#. This method has the ability to convert any whole numbers given in a textbox and it will automatically display to another textbox in a currency format in just a click. Let's begin.
The complete source code is included. You can download it and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application for c#.
Step 2
Add two labels, two textboxes and a button in the form. After that, design the form just like shown below.
Step 3
Double click the button and do the following codes to convert the whole number in a currency format when the button is clicked.- private void button1_Click(object sender, EventArgs e)
- {
- Decimal currency;
- currency = decimal.Parse(textBox1.Text);
- if(currency >= 0)
- {
- textBox2.Text = currency.ToString("##,###.00");
- }
- else
- {
- currency = Math.Abs(currency);
- textBox2.Text = currency.ToString("##,###.00") + "-";
- }
- }
Output

Add new comment
- 493 views