Table of Contents

Class FastTimeSpanParser

Namespace
Ecng.Common
Assembly
Ecng.Common.dll

Provides high-performance parsing and formatting of TimeSpan values based on a specified template.

public class FastTimeSpanParser
Inheritance
FastTimeSpanParser
Inherited Members
Extension Methods

Constructors

FastTimeSpanParser(string)

Initializes a new instance of the FastTimeSpanParser class using the specified template.

public FastTimeSpanParser(string template)

Parameters

template string

A format template that defines how TimeSpan values are parsed and formatted. Must not be null or empty.

Exceptions

ArgumentNullException

Thrown when the provided template is null or empty.

Properties

Template

Gets the template string used for parsing and formatting TimeSpan values.

public string Template { get; }

Property Value

string

Methods

Parse(string)

Parses the specified input string into a TimeSpan value based on the parser's template.

public TimeSpan Parse(string input)

Parameters

input string

The string representation of a time span to parse.

Returns

TimeSpan

A TimeSpan value that corresponds to the given input.

Exceptions

InvalidCastException

Thrown when the input cannot be converted to a TimeSpan using the provided template.

ToString()

public override string ToString()

Returns

string

ToString(TimeSpan)

Formats the specified TimeSpan value into a string using the parser's template.

public string ToString(TimeSpan value)

Parameters

value TimeSpan

The TimeSpan value to format.

Returns

string

A string representation of the TimeSpan value according to the template.