Partager via


XmlConvert.ToTimeSpan Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Converts the String to a TimeSpan equivalent.

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

Syntax

'Declaration
Public Shared Function ToTimeSpan ( _
    s As String _
) As TimeSpan
public static TimeSpan ToTimeSpan(
    string s
)

Parameters

  • 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.

Exceptions

Exception Condition
FormatException

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

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.