Edit

Share via


SoapDuration.ToString(TimeSpan) Method

Definition

Returns the specified TimeSpan object as a String.

public:
 static System::String ^ ToString(TimeSpan timeSpan);
public static string ToString (TimeSpan timeSpan);
static member ToString : TimeSpan -> string
Public Shared Function ToString (timeSpan As TimeSpan) As String

Parameters

timeSpan
TimeSpan

The TimeSpan object to convert.

Returns

A String representation of timeSpan in the format "PxxYxxDTxxHxxMxx.xxxS" or "PxxYxxDTxxHxxMxxS". The "PxxYxxDTxxHxxMxx.xxxS" is used if Milliseconds does not equal zero.

Examples

The following code example shows how to use the ToString method. This code example is part of a larger example that is provided for the SoapDuration class.

// Serialize a TimeSpan object as an XSD duration string.
// This object represents a time span of 399 days, 12 hours,
// 35 minutes, 20 seconds, and 10 milliseconds.
TimeSpan duration = TimeSpan(399,12,35,20,10);
Console::WriteLine( L"The duration in XSD format is {0}.",
   SoapDuration::ToString( duration ) );
// Serialize a TimeSpan object as an XSD duration string.
// This object represents a time span of 399 days, 12 hours,
// 35 minutes, 20 seconds, and 10 milliseconds.
TimeSpan duration = new TimeSpan(399, 12, 35, 20, 10);
Console.WriteLine("The duration in XSD format is {0}.",
    SoapDuration.ToString(duration));

Applies to