how can I validate column names and count in an List array? C#
- by Christopher Klein
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...