Kate
Kate

Reputation: 945

How can I show currency symbol in a label in c#?

I am new to c# and I am using windows forms.

Anyone knows how can I show currency symbol in a label. for example:

double test = 2.5;
lable1.text = test.Tostring();  

The result will show 2.5 but I want to show it as £2.5

Please help me how to do that. Thank you

Upvotes: 2

Views: 2947

Answers (2)

Fᴀʀʜᴀɴ Aɴᴀᴍ
Fᴀʀʜᴀɴ Aɴᴀᴍ

Reputation: 6251

Use string formats like this:

double test = 2.5;
lable1.text = test.ToString("£#.#")

Just in case you want to display the decimals upto 2 places, you could use something like:

lable1.text = test.ToString("£#.##")

Upvotes: 1

Neil Hibbert
Neil Hibbert

Reputation: 862

String.Format("{0:C}",test); or test.ToString("C"); should do the trick...

Upvotes: 5

Related Questions