Convert an array of DateTime values to a string and back again
//CONVERT ARRAY OF DATE TIME TO COMMA SEPARATED STRING
array<DateTime> ^MyDateTimeArray;
String ^MyString;
MyString = "";
for (Count = 0; Count < MyDateTimeArray->Length; Count++)
MyString += MyDateTimeArray[Count].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + ",";
//CONVERT COMMA SEPARATED STRING BACK TO ARRAY OF DATE TIME
String ^sTemp;
while (1)
{
//GET THE NEXT DATATIME VALUE (they are comma seperated and there is always a trailing comma)
if (MyString->LastIndexOf(",") <= 0)
break;
sTemp = MyString->Substring(0, (MyString->IndexOf(",")-1) );
MyString = MyString->Substring( (MyString->IndexOf(",")+1) );
Array::Resize(MyDateTimeArray, (MyDateTimeArray->Length + 1));
MyDateTimeArray[(MyDateTimeArray->Length - 1)] = Convert::ToDateTime(sTemp);
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.