什么是一个很好的对象来存储3数据类型一拉列表/元组.NET 3.5 [英] What's a good object to store 3 data types a la list/tuple in .NET 3.5
问题描述
我试图验证一些数据在CSV文件中,我分析过。该用户喂我的程序一个CSV文件,我希望他们能够验证的任意组合(和/或)列第2,虽然7,并指定输出顺序。到目前为止,我所拥有的是这样的事情
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
}
}
}
我的 OrderedDataLine
对象须持有3条信息:列类型,目标列号和值进行打印。现在它看起来像这样:排序列表< DownloadSection,INT>
,其中 DownloadSection
是一个枚举每个我可能列类型。在.NET 4中,我将能够使用一个元组列表,但没有这样的运气3.5。什么样的目标的任何想法可以存储3个不同的部分信息?
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...
推荐答案
看一看这个开源的元组实现.NET 3.5
这篇关于什么是一个很好的对象来存储3数据类型一拉列表/元组.NET 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!