Converts the date and time value of this instance to a string.
[Visual Basic] Overloads Overrides Public Function ToString() As String [C#] public override string ToString(); [C++] public: override String* ToString(); [JScript] public override function ToString() : String;
A string value containing the date and time represented by this instance.
Exception Type | Condition |
---|---|
FormatException | If the general format ("G") string is used. |
The ToString method uses InvariantCulture as the default. The output of ToString must be consumable by FromString.
An unexpected FormatException occurs while using the ToSring general format ("G") string when the general format DateTime string representation is not parsed correctly.
Note ToString is formatted using the invariant culture (see InvariantCulture).
ToString converts the date and time value of this instance to a string value, then formats the return value determined by the InvariantCulture The format is " mm/dd/yy hh:mm:ss PP ", where:
DateTime Structure | DateTime Members | System Namespace | DateTime.ToString Overload List | String | CultureInfo | Calendar | DateTimeFormat | DateTimeFormatInfo