I have two arrays built while parsing a text file. The first contains the column names, the second contains the values from the current row. I need to iterate over both list
If you're really using arrays, the best way is probably just to use the conventional for
loop with indices. Not as nice, granted, but as far as I know .NET doesn't offer a better way of doing this.
You could also encapsulate your code into a method called zip
– this is a common higher-order list function. However, C# lacking a suitable Tuple type, this is quite crufty. You'd end up returning an IEnumerable
which isn't very nice.
By the way, are you really using IEnumerable
instead of IEnumerable
or why do you cast the Current
value?