What's a good object to store 3 data types a la list/tuple in .NET 3.5
Asked Answered
T

1

-1

I'm trying to validate some data in a CSV file I'm parsing through. The users feed my program a CSV file and I want them to be able to validate any combination (and/or) of columns 2 though 7 and specify the output order. So far what I have is something like this

using (StreamReader sr = new StreamReader(inputFile.FullName))
{
    while (!sr.EndOfStream)
    {
        string DataLine = sr.ReadLine();
        OrderedDataLine= GetColumnOrder(DataLine);
        if (ColumnOrderFound)  //set in GetColumnOrder
        {
            if (UserChoseToValidateCol1) { ValidateCol1(OrderedDataLine);}
            if (UserChoseToValidateCol2) { ValidateCol2(OrderedDataLine);}
            //etc... for all columns
        }
    }
}

My OrderedDataLine object is required to hold 3 pieces of information: the column type, the destination column number, and the value to be printed. Right now it looks like this: SortedList<DownloadSection, int> where DownloadSection is an enum for each of my possible column types. In .NET 4 I would be able to use a list of Tuples but no such luck in 3.5. Any ideas of what kind of object can store 3 distinct pieces of information?

I don't know if I'm tunnel visioned and maybe there's a better way to do this...

Twentyone answered 6/2, 2012 at 16:40 Comment(0)
D
0

Have a look at this open source Tuples implementation for .net 3.5

Demulcent answered 6/2, 2012 at 16:45 Comment(1)
It seems to call the Tuple Elements where they are normally called Items. Not a big deal though.Twentyone

© 2022 - 2024 — McMap. All rights reserved.