Hello i got array of string, and they are durations made by myself in format H:M:S:MS
Example strings:
0:0:4:410
0:0:1:425
0:0:1:802
0:0:1:509
0:0:1:674
0:0:1:628
0:0:2:76
How can i sum/avg/min/max values of these items in arraylist?
Arraylist name is arrayLL.
I’m new in c# so hope someone will show me how to work with strings.
The function that adds to array is:
if (Session["DT"].ToString() != "")
{
TimeSpan ts = ((DateTime)Session["DT2"]).Subtract((DateTime)Session["DT"]);
Session["TimeL"] = ts.Hours.ToString() + ":"
+ ts.Minutes.ToString() + ":"
+ ts.Seconds.ToString() + ":"
+ ts.Milliseconds.ToString();
}
Assuming the numbers represent hours, minutes, seconds, and milliseconds you can try the following:
Now you should have a list of type Integer (
durationsInMilliseconds) which contains the numbers in a single comparable format. With this, you should be able to do whichever calculations you need.(PS: If you need the result in the same format as the original input-data, you will have to add an operation for calculating back from MS into hours, minutes and seconds..)