O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

System.IFormatProvider

This interface provides important functionality, allowing a class that implements the methods defined in this interface to customize formatted output. The IFormatProvider interface provides custom formatting for ToString. Some custom format codes already exist for numeric data types, date and time formatting, and enumerators. You can also provide your own formatting by inheriting from the IFormatProvider interface and implementing the methods specified.

You might want to look in the online documentation for “Custom Numeric Format Strings” because the documentation there is much more detailed than this appendix is able to cover. Listing B.8 shows an example of formatting a double (iformatprovider.cs).

Listing B.8. Numeric ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required