How to add zero’s at the end of integer in C#

Hi,

I got the requirement to show .00 after the numbers like

Input

Output

2

2.00

2.2

2.20

2.22

2.22


We can achieve this in C# using single line of code.

double dblValue = 2.2;
string strValue = string.Format(“{0:N2}”, dblValue);

Hope this helps.


Happy Coding
Gopinath.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s