Prev | Current Page 520 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

For example, you can specify that a
double be output as a floating-point number of five significant digits with F5. Not all types are
required to support all formats except for one??”the G format??”which stands for ???general.??? In fact,
the G format is what you get when you call the parameterless Object.ToString() on most objects
in the standard library. Some types will ignore the format specification in special circumstances.
CHAPTER 14 n VB 2008 BEST PRACTICES 327
For example, a System.Double can contain special values that represent NaN (Not a Number),
PositiveInfinity, or NegativeInfinity. In such cases, System.Double ignores the format specification
and displays a symbol appropriate for the culture as provided by NumberFormatInfo.
The format specifier may also consist of a custom format string. Custom format strings
allow the user to specify the exact layout of numbers as well as mixed-in string literals. The
client can specify one format for negative numbers, another for positive numbers, and a third
for zero values. Implementing IFormattable.ToString() can be quite a tedious experience,
especially since your format string could be highly customized. However, in many cases??”and
the ComplexNumber example is one of those cases??”you can rely upon the IFormattable implementations
of standard types.


Pages:
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
dieta light Connie Talbot portal życzenia z okazji urodzin Unibet