在.NET 3.5中存储3个数据类型和列表/元组的好对象是什么

时间:2012-02-06 16:40:59

标签: .net-3.5

我正在尝试验证我正在解析的CSV文件中的一些数据。用户向我的程序提供CSV文件,我希望他们能够验证第2列到第7列的任何组合(和/或),并指定输出顺序。到目前为止我所拥有的是像这样的东西

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
        }
    }
}

我的OrderedDataLine对象需要包含3条信息:列类型,目标列号和要打印的值。现在它看起来像这样:SortedList<DownloadSection, int>其中DownloadSection是每个可能的列类型的枚举。在.NET 4中,我可以使用元组列表但在3.5中没有这样的运气。什么样的对象可以存储3个不同的信息?

我不知道我是否有隧道愿景,也许有更好的方法来做到这一点......

1 个答案:

答案 0 :(得分:0)