I'm attempting to parse a pipe delimited line of text from a file - HL7 message segment - to make the segment a property of an HL7 message object.
I think I"m fundamentally not understanding the concept of n-dimensional arrays...
The segment looks like this
MSH|^~\&||X530^X530^FID|ERIC^NSCC^RSSI|NSCCH|....
I want to create an array thusly;
First item in the array = {"0","MSH"}
Next item in the array = {"1,", "^~\&"}
Next item in the array = {"2,", null}
Next item in the array = {"3,", "X530^X530^FID"}
I get error message:
private string [,] ParseSegment(string ms)
{
int i = 0;
string[] segmentFields = ms.Split('|');//fields for this segment
int arrayLength = segmentFields.Length;
string[,] fieldAndIndex = new string[arrayLength,1];
foreach (string field in segmentFields)
{
fieldAndIndex [i,i] = {{ i,field} };//I'm not sure what to do here!!!!
}
return fieldAndIndex;
}