Saturday, March 31, 2012

Trim trailing 0 from decimal place of number

Hi,

I am having difficulty trimming any traling 0's from my decimal numbers.
I store then in the database to 2 decimal places.
This means that when they come back to my application they still diply with
all the decimal places

eg

10.00 displays as 10.00
10.10 displays as 10.10

what I would like to achieve is the following

10.00 displays as 10
10.10 displays as 10.1

many thanks in advance

cheers

martin.string.Format("{0}",10);
string.Format("{0}",10.10);

should do the trick. Actually the above behavior should be the default
behavior...

+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
-----------
Making waves on the Web

"martin" <Stuart_REMOVE_36@.yahoo.com> wrote in message
news:OXKXwadbEHA.2216@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I am having difficulty trimming any traling 0's from my decimal numbers.
> I store then in the database to 2 decimal places.
> This means that when they come back to my application they still diply
with
> all the decimal places
> eg
> 10.00 displays as 10.00
> 10.10 displays as 10.10
> what I would like to achieve is the following
> 10.00 displays as 10
> 10.10 displays as 10.1
> many thanks in advance
> cheers
> martin.

0 comments:

Post a Comment