Text files and Linq to Entities

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top