IEnumerable.Select with index

后端 未结 3 1080
一生所求
一生所求 2020-12-20 14:15

I have the following code:

 var accidents = text.Skip(NumberOfAccidentsLine + 1).Take(numberOfAccidentsInFile).ToArray();

where accidents i

3条回答
  •  爱一瞬间的悲伤
    2020-12-20 14:26

    May be this LINQ query will help you to find The formated name with Index:

    var accidents=(from acc in accidents
        select new {
            id=accidents.IndexOf(acc),
            Name = acc.Replace("\"", string.Empty)
        }).ToArray()
    

    or you can also use .ToList() for the case if you want result to be in IEnumerable format.

提交回复
热议问题