Skip to main content

Formatting Approaches

  • 2 minutes to read

The formatting mechanism allows you to format values using one of the following approaches:

  • Using the standard or custom format specifiers.

    These let you format numeric and date-time values according to predefined or custom patterns (they are all described in MSDN and can also be found in the Format Specifiers topic). For instance, a numeric value can be represented as a currency amount or a hexadecimal value, using scientific notation, etc. A date/time value can be represented in the standard Short Date. Long Date or Full Date/Time form.

    Custom format specifiers can be used to construct a new custom pattern if the standard patterns do not suit your needs. Custom text can be added to the resultant string when using custom format specifiers.

  • Using composite formatting.

    This feature extends the previous one, as it allows you to format numeric and date/time values using one of the standard or custom format specifiers, and adds any custom text to the resultant string. When formatting string values, it is also possible to add custom text to the resultant string.

    See the Composite Formatting topic for details.

  • Using a custom formatter.

    This gives you the ability to format values of any type, though you will need to format values manually via code. See the Custom Formatting topic for more details.