How do you get the index of a number in a linked list?

后端 未结 5 410
天命终不由人
天命终不由人 2021-01-14 01:50

I have a linked list constructed as follows:

LinkedList linked = new LinkedList();
var array = new int[] { 23, 55, 64, 65 };
foreach (         


        
5条回答
  •  萌比男神i
    2021-01-14 02:33

    int index = linked.Select((item, inx) => new { item, inx })
                      .First(x=> x.item == 64).inx;
    

提交回复
热议问题