SoapDuration.Parse(String) Método

Definición

Convierte el objeto String especificado en un objeto TimeSpan.

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

Parámetros

value
String

Valor String que se va a convertir.

Devoluciones

Objeto TimeSpan que se obtiene a partir de value.

Excepciones

value no contiene ni la fecha ni la hora correspondiente a alguno de los modelos de formato reconocidos.

Ejemplos

En el ejemplo de código siguiente, se muestra cómo se utiliza el método Parse. Este ejemplo de código es parte de un ejemplo más grande proporcionado para la clase SoapDuration.

// Parse an XSD duration to create a TimeSpan object.
// This is a duration of 2 years, 3 months, 9 days, 12 hours,
// 35 minutes, 20 seconds, and 10 milliseconds.
String^ xsdDuration = L"P2Y3M9DT12H35M20.0100000S";
TimeSpan timeSpan = SoapDuration::Parse( xsdDuration );
Console::WriteLine( L"The time span contains {0} days.",
   timeSpan.Days );
Console::WriteLine( L"The time span contains {0} hours.",
   timeSpan.Hours );
Console::WriteLine( L"The time span contains {0} minutes.",
   timeSpan.Minutes );
Console::WriteLine( L"The time span contains {0} seconds.",
   timeSpan.Seconds );
// Parse an XSD duration to create a TimeSpan object.
// This is a duration of 2 years, 3 months, 9 days, 12 hours,
// 35 minutes, 20 seconds, and 10 milliseconds.
string xsdDuration = "P2Y3M9DT12H35M20.0100000S";
TimeSpan timeSpan = SoapDuration.Parse(xsdDuration);
Console.WriteLine("The time span contains {0} days.",
    timeSpan.Days);
Console.WriteLine("The time span contains {0} hours.",
    timeSpan.Hours);
Console.WriteLine("The time span contains {0} minutes.",
    timeSpan.Minutes);
Console.WriteLine("The time span contains {0} seconds.",
    timeSpan.Seconds);

Se aplica a