I have the following code:
var accidents = text.Skip(NumberOfAccidentsLine + 1).Take(numberOfAccidentsInFile).ToArray();
where accidents is an array of strings.
I want to make a Linq transformation from the string array to an array of Accident objects as follows:
return accidents.Select(t => new Accident() {Id = i, Name = t.Replace(""", string.Empty)}).ToArray();
How do I retrieve the index i from the accidents array using Linq or do I have to go old school?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…