I am working on a data conversion job which comes in '^' delimited with several rows per record depending on how many transactions they have made. The first field in each transaction row starts with "0411". There could be up to 27 transaction rows per record, perhaps more in futire data files. I think there is a much simpler way of reading in the transaction rows so that it just loops round until the final transaction.

I'd be happy creating the actual loop, but the bit I am stuck on is this - can you loop round & add a sequential number to field names? Each transaction has a date, a balance, an 'in' & an 'out'. For example, could I change the below to a loop which changes the number on the end of the field names (e.g. process DateYear1 the first time round and then change it to DateYear2 the next time round the loop?).

I assume I'd have to create all of them in the class still, but if there's a quicker way than copying the below 27 times and changing the number I'd like to try it!

Thanks in advance,

Greg




if (fields[0] == "0411")

{




data.RowType = fields[0];

data.DateYear1 = fields[4];

data.DateMonth1 = fields[5];

data.DateDay1 = fields[6];

data.Description1 = fields[7];

data.In1 = fields[8];

data.Out1 = fields[9];

data.Balance1 = fields[10];

oneLine = reader.ReadLine();

fields = oneLine.Split('^');

}