Monday, March 12, 2012

what is the difference bettween string.Format("{0:#.##}", and string.Format("{0:0.00}"

they both seem to do the same thing, what is the difference functionality that # versus 0 ?

string.Format("{0:#.##}", mydecimal);

string.Format("{0:0.00}", mydecimal);

Look here:http://msdn2.microsoft.com/en-us/library/0c899ak8.aspx

Hope it helps


Hi,

As far as I know, they both are different.

0.00 can remain the position all the time. For example, decimal is 0.1 and then it will return to you with 0.10 by 0.00 format.

With #.##, it will cut the unnecessary position in the decimal. For example, decimal is 0.1 and then it will return to you with .1 by #.## format.

Hope this can helps.

0 comments:

Post a Comment