By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Formatting decimals

P: n/a
C
Hi,

I have an aspx with some labels.

I set the text of these labels to be teh return value of
some Functions that carry out some calculations.
(My Functions return decimals)

I want to format the value I write to my label so that it
is transformed for example from 87123.13 to 87,123.13

This probably quite simple but I am unsure.

Any help or direction to online help much appreciated.

Thanks,
C
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
C <c@nospam.com> wrote:
I have an aspx with some labels.

I set the text of these labels to be teh return value of
some Functions that carry out some calculations.
(My Functions return decimals)

I want to format the value I write to my label so that it
is transformed for example from 87123.13 to 87,123.13

This probably quite simple but I am unsure.


You need the "number" format specifier, "n". For instance:

using System;

class Test
{
static void Main()
{
decimal d = 87123.13m;
Console.WriteLine ("{0:n}", d);
}
}

prints

87,123.13
(in an English culture).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.