views:

602

answers:

1

What I want is something like this:

String.Format("Value: {0:%%}.", 0.8526)

Where %% is that format provider or whatever I am looking for. Should result: Value: %85.26..

I basically need it for wpf binding, but first let's solve the general formatting issue:

<TextBlock Text="{Binding Percent, StringFormat=%%}" />
+8  A: 

Use the P format string. This will vary by culture:

String.Format("Value: {0:P2}.", 0.8526) // formats as 85.26 % (varies by culture)
Michael Haren
I always upvote answers that answer the question and point out the things that might bite you (like culture issues).
Martinho Fernandes
Shoot! that was really quick!
Shimmy