相关疑难解决方法(0)

TimeSpan FormatString,可选小时

我有一个时间跨度,ts大多数是分钟和秒,但有时是几个小时.我想ts返回一个格式化的字符串,它会给出以下结果:

3:30 (hours not displayed, showing only full minutes)
13:30 
1:13:30 (shows only full hours instead of 01:13:30)
Run Code Online (Sandbox Code Playgroud)

到目前为止,我有:

string TimeSpanText = string.Format("{0:h\\:mm\\:ss}", MyTimeSpan);
Run Code Online (Sandbox Code Playgroud)

但它没有给出上述结果.我怎样才能达到我想要的效果?

c# asp.net

14
推荐指数
2
解决办法
4842
查看次数

标签 统计

asp.net ×1

c# ×1