Athul Athul - 1 year ago 85
ASP.NET (C#) Question

String.Format an integer to use a thousands separator with decimal value in danish culture

I have a string

which holds a value like this

I want two things.

1)round the value so that there is always two digits after

2)Implement thousands separator in this string, So that final out put will be some thing like this

I have tried some thing like this

String.Format("{0:0.00}", totalPRice)

It does my first requirement correctly by producing an output
But I am way behind in my second requirement. Can any one tell me how I can achieve this?

Note: In danish culture
stands for
stands for

Answer Source

You can refer to Standard Numeric Format Strings and use

string.Format("{0:N2}", 1234.56)

You may also specify the culture manually, if danish is not your default culture:

var danishCulture = CultureInfo.CreateSpecificCulture("da-DK");
string.Format(danishCulture, "{0:N2}", 1234.56);

see MSDN Reference for CultureInfo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download