Questions tagged [formatprovider]

2 questions
250
votes
7 answers

Format decimal for percentage values?

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…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
35
votes
8 answers

Best practices for serializing objects to a custom string format for use in an output file

I was just about to implement an override of ToString() on a particular business class in order to produce an Excel-friendly format to write to an output file, which will be picked up later and processed. Here's what the data is supposed to look…
Chris McCall
  • 10,317
  • 8
  • 49
  • 80