Mono Class Library: System.DateTime Overview | Members

System.DateTime.ToString Method

Returns a string representation of the value of the current instance.

public string ToString (string format, IFormatProvider provider)

Parameters

format
A string containing a character that specifies the format of the returned string.
Note: For a list of valid values, see System.Globalization.DateTimeFormatInfo .
provider
A IFormatProvider that supplies a System.Globalization.DateTimeFormatInfo instance containing culture-specific formatting information.

Returns

A string representation of the current instance formatted as specified by format. The string takes into account the information in the System.Globalization.DateTimeFormatInfo supplied by provider.

Exceptions

TypeReason
FormatException

The length of the format string is 1, and it is not one of the format specifier characters defined for System.Globalization.DateTimeFormatInfo.

-or-

The format string does not contain a valid custom format pattern.

Remarks

If provider is null or a System.Globalization.DateTimeFormatInfo cannot be obtained from provider, the formatting information for the current system culture is used.

If format is a null reference, the general format specifier "G" is used.

Note:

For more information regarding the standard format specifier, see System.Globalization.DateTimeFormatInfo. For information on formatting system-supplied data types, see the IFormattable interface.

This method is implemented to support the IFormattable interface.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0