C# TimeSpan ToString()
Description
TimeSpan ToString()
converts the value of the current
TimeSpan object to its equivalent string representation.
Syntax
TimeSpan.ToString()
has the following syntax.
public override string ToString()
Returns
TimeSpan.ToString()
method returns The string representation of the current TimeSpan value.
Example
The following example displays the strings returned by calling the ToString method with a number of TimeSpan values.
using System;/*ww w .jav a 2 s .c o m*/
public class ToString
{
public static void Main()
{
TimeSpan span;
// Initialize a time span to zero.
span = TimeSpan.Zero;
Console.WriteLine(span);
// Initialize a time span to 14 days.
span = new TimeSpan(-14, 0, 0, 0, 0);
Console.WriteLine(span);
}
}
The code above generates the following result.