C# 如何用秒初始化时间跨度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/719186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I initialize a timespan with seconds
提问by Brad
I have a variable(double) that holds a acumulation of seconds.
我有一个变量(double),它保存了秒的累积。
I would like to use timespan to format this into hours:min:seconds for display purposes, but I can't seem to find how I would assign this acumulated value to a timespace.
我想使用 timespan 将其格式化为 hours:min:seconds 以用于显示目的,但我似乎无法找到如何将此累积值分配给时间空间。
C# .net 2.0
C# .net 2.0
采纳答案by Ryan Lundy
Use the TimeSpan.FromSecondsmethod.
使用TimeSpan.FromSeconds方法。