The best things to do are:
1) Stop using ArrayList - it was superseded by generic collections in V2 of .NET!
2) Create a class to hold the values, and give it a constructor which takes a string.
First, split each string using string.Split:
Then use DateTime.TryParseExact to convert each date to a DateTime value, and intTryParse to convert the ID:
private class MyData
{
private int _ID;
public int ID
{
get { return _ID; }
set { _ID = value; }
}
private DateTime _Date;
public DateTime Date
{
get { return _Date; }
set { _Date = value; }
}
private string _Type;
public string Type
{
get { return _Type; }
set { _Type = value; }
}
public MyData(string s)
{
string[] parts = s.Split(';');
if (parts.Length != 3) throw new ArgumentException("Not a valid MyData element: " + s);
if (!int.TryParse(parts[0], out _ID)) throw new ArgumentException("Bad ID Value: " + parts[0]);
if (!DateTime.TryParseExact(parts[1], "yyyy-M-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out _Date)) throw new ArgumentException("Bad date format: " + parts[1]);
_Type = parts[2];
}
}
Use each string to generate a new instance of MyData, and store them in a List<MyData>
Then it's pretty trivial to use a Linq query (or even a foreach loop) to get the totals grouped by date, ID, or both.