我正在尝试验证我正在解析的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个不同的信息?
我不知道我是否有隧道愿景,也许有更好的方法来做到这一点......