다음을 통해 공유


SoapDuration.Parse(String) 메서드

정의

지정된 StringTimeSpan 개체로 변환합니다.

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

매개 변수

value
String

변환할 String입니다.

반환

value에서 가져온 TimeSpan 개체입니다.

예외

value에 인식된 형식 패턴에 해당하는 날짜와 시간이 포함되지 않은 경우

예제

다음 코드 예제에서는 Parse 메서드를 사용하는 방법을 보여 줍니다. 이 코드 예제는 제공 된 큰 예제의 일부는 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);

적용 대상