TimeSpan::ToString Method (String)
Converts the value of the current TimeSpan object to its equivalent string representation by using the specified format.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- format
- Type: System::String
A standard or custom TimeSpan format string.
Return Value
Type: System::StringThe string representation of the current TimeSpan value in the format specified by the format parameter.
| Exception | Condition |
|---|---|
| FormatException | The format parameter is not recognized or is not supported. |
The format parameter can be any valid standard or custom format specifier for TimeSpan values. If format is equal to String::Empty or is nullptr, the return value of the current TimeSpan object is formatted with the common format specifier ("c"). If format is any other value, the method throws a FormatException.
If format is a standard format string, the format of the returned string is defined by the formatting conventions of the current culture.
The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:
For more information about format strings for TimeSpan values, see Standard TimeSpan Format Strings and Custom TimeSpan Format Strings.
For more information about support for formatting in the .NET Framework, see Formatting Types.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.