R
RBScheer
Hi.
I am reading a text file using Linq, but can't get Linq to generate an
index for each read line. I am using this code:
Dim txt = From line In File.ReadAllLines("c:\data.txt").Skip(1) Where
line.Length > 0 _
Let fields = line.Split(";") _
Select New MyClass With {.Company = fields(0), .Name =
fields(1), .Limit = fields(2)}
It reads the text file succesfully, but I need to get the index from
each line. I know there's an overload to the Select method that gets
the index of each line. But it is not working on my situation, since
the MyClass class does not have a default indexer property. I tried to
create this default property but it is never reached during the above
code run. Is it possible to give an index to each line using the above
code?
Regards,
Robert Scheer
I am reading a text file using Linq, but can't get Linq to generate an
index for each read line. I am using this code:
Dim txt = From line In File.ReadAllLines("c:\data.txt").Skip(1) Where
line.Length > 0 _
Let fields = line.Split(";") _
Select New MyClass With {.Company = fields(0), .Name =
fields(1), .Limit = fields(2)}
It reads the text file succesfully, but I need to get the index from
each line. I know there's an overload to the Select method that gets
the index of each line. But it is not working on my situation, since
the MyClass class does not have a default indexer property. I tried to
create this default property but it is never reached during the above
code run. Is it possible to give an index to each line using the above
code?
Regards,
Robert Scheer