myTimeSpan.ToString("hh:mm");
但是发生这个错误:
input string was not in a correct format
这样做的正确方法是什么?
解决方法myTimeSpan.ToString(@"hh\:mm")
Custom TimeSpan Format Strings
总结The custom TimeSpan format specifIErs do not include placeholder separator symbols,such as the symbols that separate days from hours,hours from minutes,or seconds from fractional seconds. Instead,these symbols must be included in the custom format string as string literals. For example,“dd.hh\:mm” defines a period (.) as the separator between days and hours,and a colon (:) as the separator between hours and minutes.
以上是内存溢出为你收集整理的c# – 如何将TimeSpan转换为24小时和分钟字符串?全部内容,希望文章能够帮你解决c# – 如何将TimeSpan转换为24小时和分钟字符串?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)