Converts TimeSpan to string using the specified format and culture-specific formatting information.
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
TimeSpan[] intervals = { new TimeSpan(3, 3, 3)};
CultureInfo[] cultures = { new CultureInfo("en-US"),
new CultureInfo("fr-FR") };
string[] formats = {"c", "g", "G" };
foreach (var interval in intervals) {
foreach (var fmt in formats){
Console.WriteLine("{0,16} {1,6} {2,22} {3,22}",
interval, fmt,
interval.ToString(fmt, cultures[0]),
interval.ToString(fmt, cultures[1]));
}
}
}
}
Related examples in the same category