how can I validate column names and count in an List array? C#

Posted by Christopher Klein on Stack Overflow See other posts from Stack Overflow or by Christopher Klein
Published on 2010-05-10T13:17:56Z Indexed on 2010/05/10 14:04 UTC
Read the original article Hit count: 265

Filed under:
|
|

I'm trying to get this resolved in .NET 2.0 and unfortunately that is not negotiable.

I am reading in a csv file with columns of data that 'should' correspond to a List of tickers in IdentA with some modifications. The csv file columsn would read: A_MSFT,A_CSCO,_A_YHOO,B_MSFT,B_CSCO,B_YHOO,C_MSFT,C_CSCO,C_YHOO

IdentA[0]="MSFT"
IdentA[1]="CSCO"
IdentA[2]="YHOO"

The AssetsA array is populated with the csv data
AssetsA[0]=0
AssetsA[1]=1.1
AssetsA[2]=0
AssetsA[3]=2
AssetsA[4]=3.2
AssetsA[5]=12
AssetsA[6]=54
AssetsA[7]=13
AssetsA[8]=0.2

The C_ columns are optional but if they exist they all need to exist. All of the suffixes must match the values in IdentA. The values in the csv files all need to be decimal. I'm using a group of 3 as an example, there could be any number of tickers in the IdentA array.

Its easy enough to do the first part:

for (int x = 0; x < IdentA.Count; x++)
                        {

                            decimal.TryParse(AssetsA[x + IdentA.Count], out currentelections);
                        }

So that will get me the first set of values for the A_ columns but how can I get through B_ and C_ ? I can't do something as simple as IdentA.Count*2...

© Stack Overflow or respective owner

Related posts about c#2.0

Related posts about list