using VS9.0, C#
I am having a tough time getting my data into an array. I am reading data from a serial port. I get a long string that looks like so:
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,
I want an array that looks like this:
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n, (one record)
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,
XXXX, XX/XX/XX, XX:XX, XXXXXXXX\r\n,
There is no way to tell how many records will be coming in...the max amount is 300
I am using the serialPort's datareceived event to grab the string...I have an idea how I think I can get what I want:
1) take the long string and spilt it at each '\r\n' to make a 1-d array**
2) count the number of elements in that array (to get number of records for 2-d array initializing)
3) get a 2-d array [numOfRecords, 4]
4) spilt each element of the 1-d array at each ',' and put into the new 2-d array
**where I got stuck (don't know how many records...can't set size of array...now, i am lost).
if anyone has a good idea how I can do this...or any suggestions, it would be much appreciated.
Thanks!
(PS. I would post my code...but it's a big load of crap that doesn't work...i'm ashamed)