XmlConvert.ToTimeSpan Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Converts the String to a TimeSpan equivalent.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public static TimeSpan ToTimeSpan(
	string s


Type: System.String

The string to convert. The string format must conform to the W3C XML Schema Part 2: Datatypes recommendation for duration.

Return Value

Type: System.TimeSpan

A TimeSpan equivalent of the string.

Exception Condition

s is not in correct format to represent a TimeSpan value.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top