I am compiling in C# using .NET 3.5 and am trying to convert a TimeSpan to a string and format the string. I would like to use
myString = myTimeSpan.ToString("c");
however the TimeSpan.ToString
method does not take a format string as an argument until .NET 4.0 and I am using .NET 3.5.
How then would you format a TimeSpan as a string? My final goal is to display the TimeSpan in format hh:mm:ss
but am currently receiving hh:mm:ss:fffffff
.
I have tried using
myString = string.Format("{0:hh:mm:ss}", myTimeSpan);
but string.Format is only formatting my DateTime and passing different format strings doesn't work when trying to format a TimeSpan.