如何将时间戳数组转换为double [英] How to convert a timestamp array to a double

查看:482
本文介绍了如何将时间戳数组转换为double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有一个.CSV文件,第一列有时间戳(HH:mm:ss:mss)。

我已将这些值以字符串格式导入到数据表中,并且我试图在Zed图X轴上绘制具有这些值的图形。

尝试将其转换为使用时的两倍,

 double [] result1 = time.Select< string,double>(s => Double.Parse(s))。ToArray< double>(); 



我收到错误。

由于Zed图只接受双倍值,我试图解决这个问题。



任何人都可以帮我这个。



-Thanks in Advance。

解决方案

< blockquote>对于你的数组中的ecah值:

1.首先应该使用 DateTime 对象中的时间字符串值进行转换> DateTime.Parse();



2.然后转换 DateTime 对象使用 Ticks double 值c> property;


尝试使用Convert.ToDouble(s)

而不是Double.parse





如果这不起作用你能告诉我们你的错误吗?

如果文化不同,他可能无法识别字符串


TimeSpan.TryParseExact [< a href =http://msdn.microsoft.com/en-us/library/dd784009(v=vs.110).aspx\"target =_ blanktitle =New Window> ^ ]解析。然后,通过 TotalMilliseconds [ ^ ]财产。它已经是双倍。


Hello,

I have a .CSV file with first column having time stamps(HH:mm:ss:mss).
I have imported these values into a data table in string format and I am trying to plot a graph with these values on Zed graph X axis.
While trying to convert it to double using,

double[] result1 = time.Select<string, double>(s => Double.Parse(s)).ToArray<double>();


I am getting an error.
As Zed graph accepts only double values, I am stuck trying to resolve this problem.

Can any one help me with this.

-Thanks in Advance.

解决方案

For ecah value from your array:
1.First you should convert from time string value in DateTime objects by using DateTime.Parse();

2.Then convert the DateTime object to double value by using Ticks property;


Try using Convert.ToDouble(s)
instead of Double.parse


If this doesn't work can you show us your error?
It is possible he doesn't recognises the string if the culture is different


Let TimeSpan.TryParseExact[^] do the parsing. Then, get the number of milliseconds via the TotalMilliseconds[^] property. It's already a double.


这篇关于如何将时间戳数组转换为double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆