I have the following code:
int sec = 62;
string str = string.Format("Time: {0:xxx}", sec);
What should I type in the place of xxx if I want an output like this: Time: 00:01:02?
I know I can type:
string.Format("Time: {0:xxx}", TimeSpan.FromSeconds(sec));
or similar but the only part I can change is the xxx part.
Any ideas?
Since the format string cannot change the type of its arguments there is no other option than the one you cannot use.
After all,
intis a type that contains numbers (fundamentally, at least), not time spans and thus why would anintbe formattable as a time span?