Wednesday 10 June 2015

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.

No comments:

Post a Comment