using System;
public class ToString
{
public static void Main()
{
TimeSpan span;
// Initialize a time span to zero.
span = TimeSpan.Zero;
Console.WriteLine(FormatTimeSpan(span, true));
}
private static string FormatTimeSpan(TimeSpan span, bool showSign)
{
string sign = String.Empty;
if (showSign && (span > TimeSpan.Zero))
sign = "+";
return sign + span.Days.ToString("00") + "." +
span.Hours.ToString("00") + ":" +
span.Minutes.ToString("00") + ":" +
span.Seconds.ToString("00") + "." +
span.Milliseconds.ToString("000");
}
}